[英]PHP - How to store user's preference (Mobile or full site) without using Cookies
I need to be able to load the user's previously set preference (within the same session, doesn't have to persist between sessions) of if they want to view the mobile version or full version of the site. 我需要能够加载用户先前设置的偏好设置(在同一会话中,不必在会话之间持久),如果他们想要查看网站的移动版本或完整版本。
I would like to achieve this via a cookieless approach, however I am pretty sure that storing stuff in the $_SESSION variable will write to a cookie. 我想通过无cookie的方法来实现这一点,但是我很确定将内容存储在$ _SESSION变量中会写入cookie。
Is there a better way of doing this? 有更好的方法吗?
Thank you! 谢谢!
Xavier. 泽维尔。
You can disable cookies for the session: 您可以为该会话禁用Cookie:
ini_set('session.use_cookies', 0);
ini_set('session.use_only_cookies', 0);
ini_set('session.use_trans_sid', 1);
this will force any client to append his session-id to every request he makes in order to authenticate. 这将迫使任何客户端将其会话ID附加到他提出的每个请求中以进行身份验证。 (Well actualy your server will append it to any generated link, so the client includes it automatically)
(实际上,您的服务器会将其附加到任何生成的链接,因此客户端会自动包括它)
However, this has several drawbacks: 但是,这有几个缺点:
First of there is 2 kinds of cookies. 首先是2种Cookie。
The $_SESSION variable contains the variables you set on the server linked to the users session. $ _SESSION变量包含您在服务器上设置的链接到用户会话的变量。
You can disable the session cookie and only use query parameters in php.ini 您可以禁用会话cookie,仅在php.ini中使用查询参数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.