PHP 如何管理会话?
How does PHP manage session?
我最初认为 php
存储了一个 session ID
cookie
并根据此 cookie 识别用户。此 cookie
会在浏览器关闭后立即过期。
我正在实施 remember me
功能,所以我登录时记住了我。然后我关闭浏览器再打开,但它并没有通过我存储的cookie登录,而是session变量中仍然保存着登录信息。这似乎很奇怪。
所以问题是,这些 session variables
是如何在浏览器关闭并再次打开后仍然存在的?
大多数情况下,这取决于浏览器。有的浏览器喜欢最新版的IE,就没有出现过这个问题。关闭浏览器后,所有会话变量都将被销毁。但在 Google Chrome 中它不会发生。
此外,会话变量 URL 敏感。如果您在 URL 上创建了会话,请说 http://www.example.com then these session variables are restricted to this specific address only. If you open your page with this URL http://example.com then you will see that there are no session variables this time though the destination is same for both the pages. So keep in mind to redirect your page as according to the URL you used to store session variables. For more related information on session variable problems, visit this link
我最初认为 php
存储了一个 session ID
cookie
并根据此 cookie 识别用户。此 cookie
会在浏览器关闭后立即过期。
我正在实施 remember me
功能,所以我登录时记住了我。然后我关闭浏览器再打开,但它并没有通过我存储的cookie登录,而是session变量中仍然保存着登录信息。这似乎很奇怪。
所以问题是,这些 session variables
是如何在浏览器关闭并再次打开后仍然存在的?
大多数情况下,这取决于浏览器。有的浏览器喜欢最新版的IE,就没有出现过这个问题。关闭浏览器后,所有会话变量都将被销毁。但在 Google Chrome 中它不会发生。
此外,会话变量 URL 敏感。如果您在 URL 上创建了会话,请说 http://www.example.com then these session variables are restricted to this specific address only. If you open your page with this URL http://example.com then you will see that there are no session variables this time though the destination is same for both the pages. So keep in mind to redirect your page as according to the URL you used to store session variables. For more related information on session variable problems, visit this link