[英]get value from sessionStorage in Laravel 5.1
I am storing user_id
value in sessionStorage
using javascript as 我存储
user_id
价值sessionStorage
使用JavaScript作为
sessionStorage.setItem('user_id',id);
I want to pull this value form sessionStorage in php file, How I can do it. 我想从php文件中的sessionStorage中提取此值,我该怎么做。 I used php
$_SESSION
super global but it returns an error. 我使用php
$_SESSION
超级全局,但返回错误。 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
. 我使用了laravel的内置会话函数,但是它从我不知道的位置存储/检索值,但从
session storage
检索的值。
No can do... 没办法...
sessionStorage
is client side, and stored on the users machine. sessionStorage
是客户端,存储在用户计算机上。 PHP is server side. PHP是服务器端。 PHP can not access anything on the client computer (luckily).
PHP无法访问客户端计算机上的任何内容(幸运的是)。 You'll have to explicitly send that
user_id
along with you request (trough GET or POST variables ie). 您必须明确地将
user_id
与您的请求一起发送(通过GET或POST变量,即)。
Perhaps the easiest way here would be to store that user_id
as a cookie . 也许最简单的方法是将
user_id
存储为cookie 。 That way it gets send along with every request, and can be accessed both by javascript and php. 这样,它就随每个请求一起发送,并且可以通过javascript和php进行访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.