开发者

setcookie problem IE8

开发者 https://www.devze.com 2023-01-07 21:47 出处:网络
I cannot get setcookie to work with IE8. My script works fine in IE7, Firefox and Safari, but it doesn\'t seem to work in IE8 running on Windows7 and I\'m getting desperate!

I cannot get setcookie to work with IE8. My script works fine in IE7, Firefox and Safari, but it doesn't seem to work in IE8 running on Windows7 and I'm getting desperate!

I'm using a very short small test script now:

<?php
$value = 'content';
setcookie("CookieTest", $value, 0);
?>

With Firefox this works fine, the cookie is being created in my temp file folder without any problem. When I run th开发者_运维技巧is script in IE8, no cookie is being created. I have even already put Privacy to the lowest level so that all cookies should be accepted. But even then, no luck.

Anyone any idea what could be wrong here?

Thanks, Geert


Test it :

setcookie("cook_name", hash($vid), time()+3600); 
setcookie('cook_name', hash($vid), time() + 60 * 60 * 24 * 30, '/', $_SERVER['HTTP_HOST']);


Try using Fiddler to see if the Set-Cookie header is being included in the page response, to see if it's a client or server-side issue.

We're recently encountering what may be a bug in IE8 (perhaps introduced in a recent Windows Update?) Occasionally we update a cookie's value using a Set-Cookie header in a HTTP response. The cookie's value is updated, as we can see the new value being sent in the headers of subsequent HTTP requests. But after a couple of seconds, the cookie seems to "disappear" and no subseqent requests contain the cookie.

I can't find anything in our own client-side code that would delete the cookie, and I've traced the requests and responses to the server in Fiddler, and no Set-Cookie header is deleting the cookie either.

We're working around this issue by setting the cookie from Javascript code instead.


I had the same problem, but I discovered that as long as the script is not executed in localhost, it works perfectly. So I had to upload to my host and test, instead of my local development environment.

You probably don't need this answer anymore but hopefully someone else will find this useful.

0

精彩评论

暂无评论...
验证码 换一张
取 消