Jump to content

[SOLVED] Logout Error


Lamez

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.