I've searched around for use of localStorage in PHP, as I need to get localStorage data as a $var, in PHP and do stuff in PHP with it. Is this possible?
4
-
1You can read diveintohtml5.info/storage.htmlyPhil– yPhil2013-09-11 13:44:46 +00:00Commented Sep 11, 2013 at 13:44
-
1I see that this page has entered the reopen review queue. The thing about reopening isn't just that the question is valid; it is that it must also be a good question. These early SO questions tend to be requirements dumps or essentially ask for help without a shred of posted effort. Compare this page to the more recent: stackoverflow.com/q/25191944/2943403 & stackoverflow.com/q/21336996/2943403. SO will invariably grow better content if more complete questions are posted. I am not sure if I'm on board with reopening this one because it sets bad precedence regarding how to ask.mickmackusa– mickmackusa ♦2020-12-24 20:24:52 +00:00Commented Dec 24, 2020 at 20:24
-
1Also in this dupe cluster: stackoverflow.com/q/22609986/2943403 , stackoverflow.com/q/49829703/2943403 , stackoverflow.com/q/39038225/2943403 , stackoverflow.com/q/44834919/2943403 , stackoverflow.com/q/10923813/2943403 , stackoverflow.com/q/30163855/2943403 , and many more.mickmackusa– mickmackusa ♦2020-12-24 20:36:09 +00:00Commented Dec 24, 2020 at 20:36
-
1Since this question is seeking a complete tutorial / off-site resource AND the answer shows about as much detail as the question, I am not compelled to reopen this old, low-value page.mickmackusa– mickmackusa ♦2020-12-24 20:38:41 +00:00Commented Dec 24, 2020 at 20:38
Add a comment
|
1 Answer
localStorage is something that is kept on the client side. There is no data transmitted to the server side.
You can only get the data with JavaScript and you can send it to the server side with Ajax.
7 Comments
Braden Best
If php can access cookies, why the hell can't it access localStorage?
Felix Kling
@B1KMusic: Because cookies are sent to the server in the request headers. It's not that PHP can access the client side. The browser sends the cookie data to the server.
DavidG
I know this is correct, but could you update the answer to show how?
Chuck Le Butt
@FelixKling That explains the server READING cookie data, so how about WRITING it?
Felix Kling
@ChuckLeButt: The sever can send
Set-Cookie headers in the response. developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie |