note 110969 modified in function.session-unset by danbrown

From: Date: Thu, 17 Jan 2013 15:27:51 +0000
Subject: note 110969 modified in function.session-unset by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193150@lists.php.net to get a copy of this message
There is nothing magical about the $_SESSION superglobal and unsetting it. One has simply to remember that all the session_* functions will use continue to use exactly that instance of array that was set up by session_start. Consider this example: <?php session_start(); var_dump($_SESSION); $a =& $_SESSION; unset($_SESSION); $a['x'] = 1; // $a refers to the original $_SESSION $_SESSION['x'] = 2; // new unrelated array session_write_close(); // saved session contains x => 1 ?> --was-- There is nothing magical about the $_SESSION superglobal and unsetting it. One has simply to remember that all the session_* functions will use continue to use exactly that instance of array that was set up by session_start. Consider this example: <?php session_start(); var_dump($_SESSION); $a =& $_SESSION; unset($_SESSION); $a['x'] = 1; // $a refers to the original $_SESSION $_SESSION['x'] = 2; // new unrelated array session_write_close(); // saved session contains x => 1 http://php.net/manual/en/function.session-unset.php

« previous php.notes (#193150) next »