Lamez Posted May 19, 2007 Share Posted May 19, 2007 I have a login system and when I logout, I am still logged in! I do not know why. Here is the script that keeps user's from viewing unless they are logged in! <?php $username = $_COOKIE['loggedin']; if (!isset($_COOKIE['loggedin'])) die("You are not logged in, <a href=login.php>click here</a> to login."); echo "<u>Welcome <b>$username</b></u>"; ?> Here is the logout script <?php setcookie("loggedin",time()-(3600 * 24)); setcookie("$username"); ?> How am I able to fix this? -Thanks Lamez. Link to comment https://forums.phpfreaks.com/topic/52091-solved-logout-error/ Share on other sites More sharing options...
PC Nerd Posted May 19, 2007 Share Posted May 19, 2007 well if you have a timeout on your cookie ( when you set it...... ) then simply reset the timout time, to 5 minutes before its set......... so that its automatically deleted on the page refresh..... you could even automatically relocate to eg index.php?message=logut then on index.php, add a popup to say "you are logged out" , if $_GET['message'] == "logout" etc. gdlk Link to comment https://forums.phpfreaks.com/topic/52091-solved-logout-error/#findComment-256825 Share on other sites More sharing options...
Lamez Posted May 19, 2007 Author Share Posted May 19, 2007 Well, I am very new to PHP and I am going to need help doing this. Link to comment https://forums.phpfreaks.com/topic/52091-solved-logout-error/#findComment-256827 Share on other sites More sharing options...
Lamez Posted May 19, 2007 Author Share Posted May 19, 2007 I fixed it! here is the new FIXED code. <?php setcookie("loggedin", "TRUE", time()-(3600 * 24)); setcookie("$username"); ?> Link to comment https://forums.phpfreaks.com/topic/52091-solved-logout-error/#findComment-256830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.