我正在尝试为我的 PHP 应用程序创建身份验证机制,但我很难销毁会话。我尝试取消设置先前在会话数组中设置的身份验证令牌,并通过以下方式销毁会话
session_destroy
,
以及在销毁会话之前完全重置会话数组。我正在调用标头函数,并在函数调用结束时返回到我的 index.php 页面。我也尝试过
session_write_close
处理关闭会话。当我注销用户时,我会对会话进行 vardump,并且它显示没有数据存在,但是当我返回到 index.php 页面时,我会取回用户身份验证数据。我还对 Post 数据进行了 vardump,只是为了确保我不会以某种方式重新提交 post 身份验证处理程序。
关于在这里做什么有什么建议吗?
首先,请确保您正在拨打电话session_start();
打电话之前session_destroy();
因为如果您不这样做,它只会发出警告。
另外,从PHP:会话销毁 http://www.php.net/manual/en/function.session-destroy.php:
In order to kill the session altogether, like to log the user out, the session id must also be unset. If a cookie is used to propagate the session id (default behavior), then the session cookie must be deleted. setcookie() may be used for that.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)