Forum Moderators: coopster

Message Too Old, No Replies

Killing all Session Variables

         

username

3:19 am on Sep 24, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi all,

I have a simple logout feature on a site I am building which appends "?action=out" to a url string. Once $_GET['action'] equals "out", I run a script which tries to kill the user session. This works some of the time.

I have been using the following to empty the username session, which if empty, means the user is not logged in:

unset($_SESSION['username']);
$_SESSION['username'] = "";

This seems to be not enough. I am looking to completely empty all $_SESSION variables at that given point when the "action = out" value is found, as $_SESSION['username'] is not the only variable.

Can you please help. Thanks in advance.

tomda

6:00 am on Sep 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See below

// CLEAR SESSION
session_unset();
session_destroy();
$_SESSION = array(); // (if needed)

// CLEAR COOKIE (if needed)
setcookie('NAME', '', time() - 50400, "/".$http_dir."/");