Cookies Disabled But PHP Retains Values

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ringer
Forum Newbie
Posts: 1
Joined: Tue Feb 19, 2008 7:23 am

Cookies Disabled But PHP Retains Values

Post by Ringer »

I'm a PHP newbie. Hope this question is not too basic. PHP version is 5.2.1 (Zend Core).

I disabled cookies in my browser (IE 6) and am setting a cookie in my PHP script. When I run the PHP script, I can clearly see that the cookie was not saved on my C: drive in the Cookies folder (if I enable cookies, it shows up there).

When I reload my script, it still finds the cookie in $_COOKIE. Doesn't PHP do an unset($_COOKIES) after it flushes the HTTP response to the client? I even tried adding random characters to the end of the URL to make sure the browser was not caching the last request/response
(http://www.mySystem.com/testCookie.php?rand=afdsd1231afsfd). Thanks.

Code: Select all

$noCookie = false;
if (! isset($_COOKIE['myCookieTest'])) {
   $noCookie = true;
   $expires = time() + 60; 
   $cookieValue = 'My Cookie Value <>& ' . time() ;
   setcookie('myCookieTest',$cookieValue,$expires); 
}
Chris
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Cookies Disabled But PHP Retains Values

Post by RobertGonzalez »

Cookies are two mechanisms, though what you are saying doesn't make sense.

I know that IE holds a strong cache of the pages visited. I would recommend clearing the entire cache (ctrl+f5 reload) after the settings have been changed to make sure that there are no cookies being sent with the request.
Post Reply