简体   繁体   English

各个页面的唯一会话ID

[英]Unique Session ID's for individual pages

I have unique session variables being set at different pages. 我在不同页面上设置了唯一的会话变量。 I want to make my session variables discreet and localized in its respective page. 我想让我的会话变量谨慎,并在其各自的页面中进行本地化。 The problem is that php stores a session id as a cookie for each user so that sessions are only unique to a user and not to pages. 问题是php将会话ID作为cookie存储给每个用户,因此会话仅对用户唯一,而不对页面唯一。

How do I restrict sessions on a page to page setup? 如何限制页面到页面设置中的会话?

You'd be better off using a SINGLE session ID, and storing each of your page's localized data in a sub-section of the session, eg 您最好使用单个会话ID,然后将每个页面的本地化数据存储在会话的子部分中,例如

$_SESSION['pages']['index.html'] = ...
$_SESSION['pages']['sitemap.html'] = ...

It is better to have just a single session floating around, rather than multiple ones. 最好只有一个会话,而不是多个会话。 Unless your site is very small, you run the risk of exceeding the browser's per-site cookie limit, and you'll start losing sessions as the browser deletes 'old' cookies to make space for 'new' ones. 除非您的站点很小,否则您就有超过浏览器的每个站点cookie限制的风险,并且由于浏览器删除“旧” cookie来为“新” cookie腾出空间,因此您将开始丢失会话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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