Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Varible / Session Ends

Status
Not open for further replies.

WJProctor

Programmer
Joined
Jun 20, 2003
Messages
151
Location
GB
Hi there, i have some sessions for users when they have logged in which keep their username handy, but my problem is i then want to log out, thus clearing these sessions ive tried $VaribleName="" but nothing happens it seems to remember the value. Are there any other ways i can do this?

Regards

JP
 
I assume you have looked at the PHP manual's session documentation.
Code:
<?php
// Initialize the session.
// If you are using session_name(&quot;something&quot;), don't forget it now!
session_start();
// Unset all of the session variables.
$_SESSION = array();
// Finally, destroy the session.
session_destroy();
?>

If that does not work you can always go ahead and invalidate the session cookie.
Code:
session_unset(); // or as above when using $_SESSION
setcookie (session_name(), '', (time () - 2592000), '/', '', 0);
session_destroy();
 
the length of time can be set under sessions in the php.ini file as well

To err is human, to completely mess up takes a computer. [morning]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top