Collect variable localStorage AJAX from PHP file

1

My question is whether it is possible to collect a variable in localStorage from PHP without sending it.

I intend to collect data in a query where I activate an option in a list and send a form but I want to determine if the user is logged in and this is the variable that I have in localstorage. I can not send it from the form because it is a list (or not).

Something similar to collecting the value of a $ _SESSION ['data'] in PHP.

I hope I have raised it correctly. I apologize if it is not like that.

Greetings

    
asked by rafa_pe 14.11.2016 в 17:39
source

2 answers

2

No, it is not possible. The value of localStorage is on the client side and php is server side. There is no way to transmit data just like that. The only solution is to send them. For example with ajax

    
answered by 14.11.2016 в 17:44
1

Accessing a localStorage variable using PHP without sending it is impossible, given that in order to generate this interaction between "front" (js) and "server" (php), a sending is required through ... ($. POST)

What you could do is make the list load the content by means of an AJAX request, in that case you could pass localStorage in a parameter. It is not very complex and you will find it tremendously useful for this purpose.

I hope you have explained me well, any doubt, tell me ^ _ ^

    
answered by 14.11.2016 в 17:46