Zend Namespace - Check if Session Exists

匿名 (未验证) 提交于 2019-12-03 02:29:01

问题:

All,

I am using Zend Framework and Zend_Session to do global session management for my application. I plan to clear all sessions on logout and hence am using the following code:

if($this->sessionExists()) {     $this->destroy(); } 

But it seems like it's not doing a good job.. I am getting an error:

    PHP Warning:  session_destroy() [<a href='function.session-destroy'> function.session-destroy</a>]: Trying to destroy uninitialized session  

How can I get rid of this error? Is there an alternative to sessionExists()?

回答1:

This seems to do the trick..

if($this->isStarted()) {     if($this->sessionExists())     {         $this->namespaceUnset("default");         $this->forgetMe();     } } 


回答2:

Not really answers your question about the error, but is beneficial for the question:

$nsName = 'MyNamespace'; if (Zend_Session::namespaceIsset($nsName)) {   echo $nsName.' exists'; } 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!