Logout of PHP session
Posted: Tue Oct 01, 2002 11:44 pm
How do you script the logout for a session?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
session_start();
session_destroy();
//User is logged out now
?>Code: Select all
<?php
unset($_SESSION);
?>Code: Select all
<?php
session_unset();
session_destroy();
?>It depends on how you set your session up in the first place and what version of PHP you have.Zoram wrote:How do you script the logout for a session?
Code: Select all
<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
session_start();
// Unset all of the session variables.
session_unset();
// Finally, destroy the session.
session_destroy();
?>Code: Select all
<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
session_start();
// Unset all of the session variables.
$_SESSION = array();
// Finally, destroy the session.
session_destroy();
?>