简体   繁体   中英

get value from sessionStorage in Laravel 5.1

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM