Hello dear friends..
I have some confusion in following code.


$_SESSION["name"]= "abc";


echo $_SESSION["name"];

as I am assigning value to session variable, after assigning I am destroying whole session but after destroying as I echo $_SESSION["name"] it show value.
It is printing value even session has been destroyed..
Can any one tell me its reason.

6 Years
Discussion Span
Last Post by panhwer

A quote from the PHP session_destroy manual

session_destroy() destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie. To use the session variables again, session_start() has to be called.

In order to kill the session altogether, like to log the user out, the session id must also be unset. If a cookie is used to propagate the session id (default behavior), then the session cookie must be deleted. setcookie() may be used for that.

Thanks dear...
bus still I have confusion like on same page it is showing session variable are set.
but as on second page I start session and the write print_r($_SESSION).. the output is array() mean session array have no item.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.