开发者

Zend Namespace - Check if Session Exists

开发者 https://www.devze.com 2022-12-26 09:59 出处:网络
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:

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 sess开发者_JAVA技巧ionExists()?


This seems to do the trick..

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


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

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

精彩评论

暂无评论...
验证码 换一张
取 消