Regarding clearing of session when you logout

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vidhya
Forum Newbie
Posts: 4
Joined: Wed Feb 08, 2006 11:27 pm

Regarding clearing of session when you logout

Post 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...
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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)
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Post by duk »

check session_destroy();
Post Reply