Welcome Guest, Not a member yet? Register   Sign In
$this->session->sess_destroy(); error
#1

A PHP Error was encountered

Severity: Warning

Message: session_destroy(): Trying to destroy uninitialized session

Filename: Session/Session.php

Line Number: 627


http://stackoverflow.com/questions/57528...on-destroy

If you need to just delete the session if it exists (for example in an auto called exit/logout/destructor script) and it may or may not exist, then you can use session_status to check the status.

As of PHP 5.4.0, you can check it like this:

if(session_status() == PHP_SESSION_ACTIVE)
{
session_destroy();
}
This is preferable to creating a new section just to destroy it later.

Per the PHP manual, session_status will return an integer that can be compared with the following constants:

Return Values

• PHP_SESSION_DISABLED - Returned if sessions are disabled.
• PHP_SESSION_NONE - Returned if sessions are enabled, but none exists.
• PHP_SESSION_ACTIVE - Returned if sessions are enabled, and one exists.
This allows you to write better, more efficient, and more flexible session management code.
Reply


Messages In This Thread
$this->session->sess_destroy(); error - by chaegumi - 04-04-2016, 11:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB