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
https://forums.phpfreaks.com/topic/78967-destroying-cookie-ie/
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
https://forums.phpfreaks.com/topic/78967-destroying-cookie-ie/#findComment-399678
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.