Changeset 2993

Show
Ignore:
Timestamp:
07/07/2008 08:27:40 PM (5 months ago)
Author:
Shadowhand
Message:

Updated Session::delete() to delete the session cookie when calling destroy() and added write_close() as a shutdown function to prevent odd buffer problems with some session handlers (namely Database).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/Session.php

    r2919 r2993  
    7878                        Event::add('system.send_headers', array($this, 'write_close')); 
    7979 
     80                        // Make sure that sessions are closed before exiting 
     81                        register_shutdown_function(array($this, 'write_close')); 
     82 
    8083                        // Singleton instance 
    8184                        self::$instance = $this; 
     
    103106        public function create($vars = NULL) 
    104107        { 
    105                 // Destroy any currently running session 
     108                // Destroy any current sessions 
    106109                $this->destroy(); 
    107110 
     
    246249                if (isset($_COOKIE[$name])) 
    247250                { 
    248                         // Change the cookie value to match the new session id to remove the "lag time" 
     251                        // Change the cookie value to match the new session id to prevent "lag" 
    249252                        $_COOKIE[$name] = $_SESSION['session_id']; 
    250253                } 
     
    258261        public function destroy() 
    259262        { 
    260                 if (isset($_SESSION)) 
    261                 { 
     263                if (session_id() !== '') 
     264                { 
     265                        // Get the session name 
     266                        $name = session_name(); 
     267 
    262268                        // Destroy the session 
    263269                        session_destroy(); 
    264270 
    265                         // Remove all session data 
    266                         session_unset(); 
    267  
    268                         // Delete the session cookie 
    269                         cookie::delete(self::$config['name']); 
    270  
    271271                        // Re-initialize the array 
    272272                        $_SESSION = array(); 
     273 
     274                        // Delete the session cookie 
     275                        cookie::delete($name); 
    273276                } 
    274277        }