Reputation: 2415
I am storing user_id
value in sessionStorage
using javascript as
sessionStorage.setItem('user_id',id);
I want to pull this value form sessionStorage in php file, How I can do it. I used php $_SESSION
super global but it returns an error. I used laravel's built in session function but it rather stores/retrieves values from i do not know where but not from session storage
.
Upvotes: 2
Views: 3947
Reputation: 14310
No can do...
sessionStorage
is client side, and stored on the users machine. PHP is server side. PHP can not access anything on the client computer (luckily). You'll have to explicitly send that user_id
along with you request (trough GET or POST variables ie).
Perhaps the easiest way here would be to store that user_id
as a cookie. That way it gets send along with every request, and can be accessed both by javascript and php.
Upvotes: 2