Page 1 of 1

Regarding clearing of session when you logout

Posted: Wed Feb 22, 2006 5:15 am
by vidhya
Hi,
i face some problem in my code.When i logout from the application i clear session variables using the following code:

setcookie ("Loggedin", "nobody",time()+3600);
session_unregister("uname");
session_unregister("upass");
session_unregister("ugroup");

I have a relogin option that agains take me to the home page.
The problem i face is,when i relogin with the loginid it doesnot logs in for the first time. it requires 2 time login when i login with the a different id from which i have logged out.
If i tired to login withe the same id as my logout it works fine.
If am not clear,
For example i am logging with Userid as:X
logging out and again logging with X it works fine.
But with logging as Y it requires 2 times to login.
Can u please help me in this problem.

I feel the seesion variables are not cleared...

Posted: Wed Feb 22, 2006 5:59 am
by CoderGoblin
if you wish all session variables to be cleared, rathe rthan use the cookie directly I woul use session_regenerate_id

NOTE Delete old session parameter not available for PHP4. (Stated in the description but thought I'd highlight it)

Posted: Wed Feb 22, 2006 6:10 am
by duk
check session_destroy();