Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.