Tuesday, 27 August 2013

How to Logout Via php

 // If the user is logged in, delete the session vars to log them out
session_start();
if (isset($_SESSION['agent_id'])) {
// Delete the session vars by clearing the $_SESSION array
$_SESSION = array();       if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '');
}// Destroy the session
session_destroy();
}

setcookie('agent_id', '');
setcookie('username', '');
// Redirect to the home page
$home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/index.php?data=true';
header('Location: ' . $home_url);
?>
------------

and for login via php

0 comments:

Post a Comment

Products :