Jump to content

Destroying Cookie + IE


roadshow

Recommended Posts

I'm using the login script from here. Logging out in firefox works fine. In IE, it doesn't log you out, however. It says "logged in as gone" and you have to manually delete all cookies in the browser.

 

Here's the log out code:

 

<?php
$past = time() - 100;
//this makes the time in the past to destroy the cookie
setcookie(ID_my_site, gone, $past);
setcookie(Key_my_site, gone, $past);
header("Location: login.php");
?>

 

IE reads that "gone" as a user. It doesn't work in any browser if the gone is removed.

 

Any ideas?

Link to comment
Share on other sites

 

1) It's up to the browser of how and when to delete the cookie. You can't control it from PHP (especially with IE). IE tends to delete cookies when the browser is closed and not right after a setcookie() is invoked.

2) The time in the past should be set back at least a day or more and not just 300 seconds. You're assuming the time on the client machine is the same as your server. Their clock could be set to anything (in which case the cookie may not get deleted).

3) You're not showing us all your code of how you're using the cookie. In any case, I would suggest you use PHP sessions rather than just relying on cookies alone.

 

http://us2.php.net/manual/en/function.setcookie.php

Link to comment
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.