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

(04-05-2016, 01:58 AM)projack89 Wrote:
(04-04-2016, 11:30 PM)chaegumi Wrote: A PHP Error was encountered

Severity: Warning

Message: session_destroy(): Trying to destroy uninitialized session

Filename: Session/Session.php

Line Number: 627


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)
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.

Did you have load Session Library ? Maybe in config.php like this ?
$autoload['libraries'] = array('database', 'session');

yes, autoload.php

Messages In This Thread
RE: $this->session->sess_destroy(); error - by chaegumi - 04-05-2016, 02:37 AM

Theme © iAndrew 2016 - Forum software by © MyBB