trying to delete a cookie, how hard can it be

I am trying to delete a cookie
// this is the code snippet
<?php
    setcookie ('lastForm', "", time() - 3600 );
?>
<script>
   window.location.href = "<?=$GLOBALS['HTTP_URL']?>user.php";
</script>

yet when i come back to the page it is still there

I have also tried
    setcookie ('lastForm', "", time() - 3600 ,"/" );
and
    setcookie ('lastForm', "", time() - 3600 ,"/" , "test2.mydomain.com" );

in FF if i view the cookie i see
Name      lastForm
Value      91413200523
Host        test2.mydomain.com
Path      /
Secure      No
Expires      Sun, 21 Jun 2009 15:57:48 GMT

-------------------------------------------------------------

this is driving me crazy, i must be missing something simple

thanks
Randy
pariesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

webvogelCommented:
time() - 3600 is a value in the past and not in the future, try time() + 3600
0
webvogelCommented:
sorry, I'm not working with cookies, you are rigth, delete is: time() - 3600

ok, then maybe, the cookie is deleted, but you can see it not until reloaded the page?

if not, try it with an other browser or an update of your browser

and you should check the time of your maschine and the server
0
webvogelCommented:
I tried your code and it works, but I have to put a value, else the cookie is not set:
setcookie ('lastForm', "something", time() - 3600 );
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
My logout script removes cookies.  Here is the code.  Best, ~Ray
<?php // RAY_logout.php
error_reporting(E_ALL);
 
 
define('COOKIE_LIFE', 60*60*24); // A 24-HOUR DAY IN SECONDS ( = 86,400 )
$cookie_expires	= time() - date('Z') - COOKIE_LIFE;
 
 
// CLEAR THE INFORMATION FROM THE $_SESSION ARRAY
$_SESSION = array();
 
// IF THE SESSION IS KEPT IN COOKIE, FORCE SESSION COOKIE TO EXPIRE
if (isset($_COOKIE[session_name()]))
{
   setcookie(session_name(), '', $cookie_expires, '/');
}
 
// TELL PHP TO ELIMINATE THE SESSION
session_destroy();
 
 
 
 
 
 
// CLEAR ALL COOKIES WITH THIS CODE
foreach ($_COOKIE as $key => $value)
{
   setcookie($key, '', $cookie_expires, '/');
}
 
 
// OPTIONAL - TELL CLIENT SHE IS LOGGED OUT
// echo "Bye";
 
 
// OPTIONAL - REDIRECT TO THE HOME PAGE
header("Location: /");
exit;
 
?>

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.