Wrote my own little logout script today (gives self a tiny little “geek pat on the back” :p).
Short and sweet:
*REVISED/IMPROVED SCRIPT:
<?php
session_start();
$_SESSION['logged'] = 0;
$_SESSION['username'] = ”;
$_SESSION['first_name'] = ”;
echo "<script type=’text/javascript’>
{
history.go(-1);
}
</script>";
?>
Now it will:
1) Log the user out,
2) Clear/reset current session state variables (just to be double-sure), then,
3) Set the URL to the page previous to ‘logout.php’ (which will be the page where the user was when he/she clicked ‘Logout’. We’ll safely assume that this would be a good spot to return the user).
[Code converted for webpage display using this awesome tool.]
Tags: code