关闭时销毁 PHP 会话 [英] Destroy PHP Session on closing

查看:31
本文介绍了关闭时销毁 PHP 会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个基于会话的简单登录页面.

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 会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆