Forum Moderators: coopster

Message Too Old, No Replies

trouble with session destroy(). HELP!

it doesn't seesm to destroy the session

         

vuie

7:32 am on Dec 29, 2006 (gmt 0)

10+ Year Member



Thanks for reading my post.

I have a welcome.php page, in which a session variable is already set for a logged in user. On this page there is a hyperlink, once clicked it causes a .php file to be executed.

Here is the code inside of logout.php


unset($_SESSION['username']);
session_destroy();
header("Location: http://localhost/Welcome.php");

The above code was supposed to destroy the $_SESSION and send the user back to welcome.php. As far as I know, the session variable

 $_SESSION['username'] 
should be unset when the welcome page is loaded.

But it's not. It remains set. I tested many times, for

 $_SESSION['username'] 
and it's still there. Therefore, the user is still logged in, even though he has clicked "log out" and the logout code is executed.

I'm not sure if what is going on and why. I'd appreciate it if you would share with me your insight about this. THank you.

justageek

12:44 pm on Dec 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Most likely because the session cookie is not being unset. Check out example 1 here to see how to remove the session cookie: [us3.php.net ]

JAG

vuie

3:43 am on Dec 30, 2006 (gmt 0)

10+ Year Member



Thank you very much, I'm still not clear about what the code was doing, but it works, i will investigate it later. Thanks for the tip.