Sessions

From: Date: Sat, 26 Aug 2000 19:08:15 +0000
Subject: Sessions
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-2178@lists.php.net to get a copy of this message
I'm having problems with sessions. According to the PHP manual what I'm attempting seems correct but I'm probably doing something wrong. --- in file called session.php <?php session_start(); session_register(MyVariable); $MyVariable = 1; echo "Variable before unset is: $MyVariable<br>\n"; session_unset(); echo "Variable after unset is: $MyVariable<br>\n"; if (session_destroy()) { echo "Success"; } else { echo "Failure"; } ?> The screen output this produces is: Variable before unset is: 1 Variable after unset is: Failure This suggests the "session_destroy" failed. However, it seems to have worked correctly because the session file on the server is 0 bytes in size after the script has finished executing. Should the "session_destroy" command completely delete the session file or just empty it to 0 bytes? Now on to my real problem of destroying the session from another script. --- in file called session.php <?php session_start(); session_register(MyVariable); $MyVariable = 1; echo "Variable is: $MyVariable<br>\n"; ?> --- in file called session1.php <?php session_start(); echo "Variable before unset is: $MyVariable<br>\n"; session_unset(); echo "Variable after unset is: $MyVariable<br>\n"; if (session_destroy()) { echo "Success"; } else { echo "Failure"; } ?> First I run session.php, which correctly runs and creates a session file on the server and displays "Variable is: 1" onscreen. Then I run session1.php, which displays the following onscreen: Variable before unset is: 1 Variable after unset is: Failure Not only does it report onscreen that the session isn't destroyed but the session file on the server isn't destroyed and is still 15 bytes in size. The contents of the session file after the above two scripts have executed is: MyVariable|i:1; So what am I doing wrong? How do I successfully kill the session? Thanks James

« previous php.windows (#2178) next »