Page 1 of 1

delete session

Posted: Fri Mar 09, 2007 2:20 am
by hrubos
I did it to delete session when user logout. But it seems not run, because when I logout, I can enter without loging

Code: Select all

<a href="../index.php?lo=true" class="left_link"> Logout </a><br />

if($lo==true){
 unset($_SESSION[valid_user]);
session_destroy();
}

Posted: Fri Mar 09, 2007 4:51 am
by Maugrim_The_Reaper
Check the PHP documentation for session_destroy(). A session has a few facets: the session data, the PHP Session, and the session id. Depending on how you want logouts to be handled, the best option to completely delete the session by setting the global array to array(), unsetting the session cookie to delete the session id, and then calling session_destroy().

Posted: Fri Mar 09, 2007 8:26 am
by feyd
Some bits about the posted snippet: "true" is not the same as true, i.e. all data from submissions (via URL or otherwise) are strings. Next, always always always quote your named array indices ($_SESSION[valid_user])