Probelm With session_destroy()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shwanky
Forum Commoner
Posts: 45
Joined: Thu Feb 15, 2007 1:21 am

Probelm With session_destroy()

Post by shwanky »

Anyone see why these functions are erring?

Code: Select all

function logout()
        {
                global $url;
                if(!headers_sent())
                        session_start();

                $_SESSION = array();

                if (isset($_COOKIE[session_name()]))
                        setcookie(session_name(), '', time()-42000, '/');

                session_destroy();
                //session_unset($_SESSION); // Temporary Fix
                redirect_to($url['login']);
        }

        function redirect_to($url)
        {
                if(session_id() != '')
                        session_write_close();

                header('location: ' . $url);
                exit();
        }

Code: Select all

Warning: session_destroy(): Session object destruction failed in session.inc.php on line 77

Warning: Cannot modify header information - headers already sent by (output started at session.inc.php:77) in common.inc.php on line 8
josa
Forum Commoner
Posts: 75
Joined: Mon Jun 24, 2002 4:58 am
Location: Sweden

Post by josa »

It could be related to permissions on the directory your session.save_path is set to. You get this error if PHP can't delete the session file.

/josa
shwanky
Forum Commoner
Posts: 45
Joined: Thu Feb 15, 2007 1:21 am

Post by shwanky »

josa wrote:It could be related to permissions on the directory your session.save_path is set to. You get this error if PHP can't delete the session file.

/josa
Already checked the permission. That doesn't seem to be the problem.
shwanky
Forum Commoner
Posts: 45
Joined: Thu Feb 15, 2007 1:21 am

Post by shwanky »

session_destroy() seems to be destroying the session because the physical file is being destroyed.
Post Reply