我正准备升级我的网站,在新的更新中,需要一个新的会话变量user_level。我想知道是否有服务器端,我可以结束所有会话,而不必实际编写任何代码。如果没有,我的意图是测试是否设置了变量,如果没有设置,我将破坏会话,迫使用户重新登录。所以像这样的。。
if(!$this->session->userdata['user_level'])
{
$this->session->sess_destroy();
}
userdata
是function
而不是array
读取会话文档
试试这个,
if(!$this->session->userdata('user_level'))
{
$this->session->userdata = array();
$this->session->sess_destroy();
}
如果你想unset a single session variable
,那么像一样使用它
$this->session->unset_userdata('user_level');// to remove user_level from session
读取http://ellislab.com/forums/viewthread/195025/