为什么PHP session_destroy()无法正常工作? [英] Why is PHP session_destroy() not working?

查看:69
本文介绍了为什么PHP session_destroy()无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用session_destroy()方法销毁所有会话变量,但使用此方法后,这些值不会销毁.

I tried to destroy all session variable by using the session_destroy() method, but after using this method, the values are not destroyed.

为什么session_destroy()不起作用?

还有其他方法可以销毁PHP中的会话吗?

Is there any other way to destroy the session in PHP?

if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) 
{   
    session_destroy();   
    session_unset();     
}

推荐答案

使用session_destroy()后,会话在幕后被破坏.出于某种原因,这不会影响已为此请求填充的$_SESSION中的值,但在以后的请求中将为空.

After using session_destroy(), the session is destroyed behind the scenes. For some reason this doesn't affect the values in $_SESSION, which was already populated for this request, but it will be empty in future requests.

如果需要,可以手动清除$_SESSION($_SESSION = [];).

You can manually clear $_SESSION if you so desire ($_SESSION = [];).

这篇关于为什么PHP session_destroy()无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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