Jump to content

Recommended Posts

i can't kill my cookie

 

set cookie in login

// if login is ok then we add a cookie 
$_POST['username'] = stripslashes($_POST['username']); 
$hour = time() + 3600; 
setcookie(ID_my_site, $_POST['username'], $hour); 
setcookie(Key_my_site, $_POST['pass'], $hour);

 

header

<?php
//checks cookies to make sure they are logged in 
if(isset($_COOKIE['ID_my_site'])) 
{ 
$username = $_COOKIE['ID_my_site']; 
$pass = $_COOKIE['Key_my_site']; 
}
...
reference to logout.php
echo "<a style='text-decoration:none' href='http://localhost/logout/logout.php'><FONT FACE='ariel' SIZE='2' color='#5f5f5f'>Logout</FONT></a>";
?>

 

logout.php

<?php 
if(isset($_COOKIE['ID_my_site'])) 
{ 
$username = $_COOKIE['ID_my_site']; 
$pass = $_COOKIE['Key_my_site']; 
}
$past = time() - 3900; 
//this makes the time in the past to destroy the cookie 
setcookie(ID_my_site, $username, $past); 
setcookie(Key_my_site, $pass, $past); 

header("Location: http://localhost/"); 
?> 	

Link to comment
https://forums.phpfreaks.com/topic/148118-solved-cant-kill-cookie/
Share on other sites

setcookie('ID_my_site', false); 
setcookie('Key_my_site', false);

 

Give that a try.

 

Because setting a cookie with a value of FALSE will try to delete the cookie, you should not use boolean values. Instead, use 0 for FALSE  and 1 for TRUE.

 

setcookie

 

EDIT:

If that fails, follow PFMaBismAd instructions. Also you should set the past to be at least 1 year ago, due to timezone differences.

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.