A web developer’s diary

November 14, 2006

Fixing ‘Session object destruction failed error’

Filed under: PHP — Celia @ 5:52 am

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.



  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

    Comment by OzWolverine — June 25, 2007 @ 9:06 pm | Reply

  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.

    Comment by celia — June 27, 2007 @ 2:26 pm | Reply

  3. PHP Version 5.1.2

    These code would throws PHP_Warning too!

    Comment by alpha1130 — September 6, 2007 @ 6:50 am | Reply

  4. session_start();

    sorry my last Submit

    Comment by alpha1130 — September 6, 2007 @ 6:50 am | Reply

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


    Comment by Chris — October 14, 2008 @ 9:29 am | Reply

  6. Thank you! Saved much of my time!

    Comment by anonymous — July 4, 2009 @ 6:10 am | Reply

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

    Comment by Hasmer — February 1, 2011 @ 11:52 am | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: