Browser: Cookie lost on refresh

Posted by Nirmal on Stack Overflow See other posts from Stack Overflow or by Nirmal
Published on 2010-03-29T02:20:43Z Indexed on 2010/03/31 15:03 UTC
Read the original article Hit count: 322

Filed under:
|
|
|

I am experiencing a strange behaviour of my application in Chrome browser (No problem with other browsers). When I refresh a page, the cookie is being sent properly, but intermittently the browser doesn't seem to pass the cookie on some refreshes.

This is how I set my cookie:

$identifier = / some weird string /;
$key = md5(uniqid(rand(), true));
$timeout = number_format(time(), 0, '.', '') + 43200;
setcookie('fboxauth', $identifier . ":" . $key, $timeout, "/", "fbox.mysite.com", 0);

This is what I am using for page headers:

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Thu, 25 Nov 1982 08:24:00 GMT"); // Date in the past

Do you see any issue here that might affect the cookie handling? Thank you for any suggestion.

EDIT-01:

It seems that the cookie is not being sent with some requests. This happens intermittently and I am seeing this behaviour for ALL the browsers now. Has anyone come across such situation? Is there any situation where a cookie will not be sent with the request?

Thanks again, for any guideline.

© Stack Overflow or respective owner

Related posts about php

Related posts about cookies