Fixing ‘Session object destruction failed error’

I see that there is not much documentation for this above error. This is probably a configuration problem and can be easily corrected.


Warning: session_destroy(): Session object destruction failed

Cause 1:

There is no session object in the first place.


Check whether the session data exists in the first place. Chances are that, the PHP configuration didn’t allow the session to start and hence session was not created. If this is the case, you would have first got errors similar to

Warning: session_start(): The session id contains invalid characters, valid characters are only a-z, A-Z and 0-9


session_start() permission denied.

You should check with your host to configure your session.

For the programmer:

Check out the PHP.ini file for correct session configuration. If everything seems to be correct, check for the session.save_path variable and whether that path is writable.

Cause 2:

The session files are there in your session.save_path directory but PHP is not able to delete the files on logout.


Your permissions on the sessiondata directory are incorrect. PHP cannot delete the session file it has created. Set permissions on session.save_path directory so that the PHP user can delete files.

Posted in PHP

7 thoughts on “Fixing ‘Session object destruction failed error’

  1. I’m experiencing this error:

    Warning: session_destroy() [function.session-destroy]: Session object destruction failed in /var/www/website/errorPage.php on line 21

    That Line has:

    So, I tried changing permissions, but it didn’t work, what could the problem be?

    Thanks lot

  2. @OzWolverine – Please check whether the session object exists. Chances are that, it was not created or it was destroyed prior to the execution of this code.

  3. Hopefully this will help someone, but I found the solution, at least to my problem.

    The session_regenerate_id() was causing the problem.
    I think the session was not being tracked correctly when the regenerate is issued.

    Anyhow, I changed it to:

    to delete the old session data, and the problem disappeared!

    You could also try dropping the session_regenerate_id() altogether, although you could then run into session fixation problems.


  4. I have this error on php sessions and seems cant find ways/solutions on the net, perhaps maybe you could help me. I have this error:

    Warning: session_start(): php_network_getaddresses: getaddrinfo failed: Name or service not known in [file path] on line 1 Notice: session_start(): Server tcp; (tcp 11211) failed with: php_network_getaddresses: getaddrinfo failed: Name or service not known (0) in [file path] on line 18 test1

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s