问题描述
我创建了一个基于会话的简单登录页面.
I have created a simple login page which is based on the sessions.
session_start();
并添加了一个包含该页面的注销页面
and added a logout page that contains this
session_destroy();
现在,当我关闭浏览器/页面并重新打开它时,会话的值仍然存在.
Now when I close the browser/page and reopen it, the values of the session are still there.
我想知道如何完全关闭页面/浏览器关闭时的会话.
I want to know how to completely destroy the session on page/browser close.
推荐答案
(如果使用)
session_set_cookie_params(0);
session_start();
关闭浏览器时,您的会话cookie将会被破坏...因此,在关闭浏览器之前,您的会话将是良好的. IE.登录并登录后,关闭浏览器,重新打开浏览器,再次进入该站点,您将无法登录.
Your session cookie will destroy when the browser is closed... so your session will be good until they close the browser. IE. You login, and you are logged in, you close the browser, re-open it, go to the site again, and you wont be logged in.
这篇关于在关闭时销毁PHP会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!