eyalros Posted May 30, 2007 Share Posted May 30, 2007 Hi Everyone, I created a script in my computer and the cookies worked just fine, but now after I've uploaded it to a server for some reason php cannot read the cookies. For Example, when I've uploaded this code: PHP Code: <? setcookie("super_password", "hello", time()+3600, "/"); echo "the cookie is ".$_COOKIE["super_password"]; ?> It's returns nothing (not returning "hello". even after I've clicked "Refresh"). I tried the following things: - I divided the script into 2 pages - one sets the cookie and reads it - I checked the cookies in my browser and it's ok - I used print_r($_COOKIE["super_admin]); instead of echo $_COOKIE["super_admin"]; - I removed the "/" domain section in the setcookie function Does anyone knows how can I solve this problem? Thanks! That's really important... Eyal Quote Link to comment https://forums.phpfreaks.com/topic/53517-problem-viewing-cookies/ Share on other sites More sharing options...
btherl Posted May 30, 2007 Share Posted May 30, 2007 Have you verified that your browser is sending the cookie? Storing it doesn't necessarily mean it'll send it.. though I'm not sure why it wouldn't. You might want to try with firefox if you are using IE, and see if it behaves differently. Quote Link to comment https://forums.phpfreaks.com/topic/53517-problem-viewing-cookies/#findComment-264487 Share on other sites More sharing options...
eyalros Posted May 30, 2007 Author Share Posted May 30, 2007 Have you verified that your browser is sending the cookie? Storing it doesn't necessarily mean it'll send it.. though I'm not sure why it wouldn't. You might want to try with firefox if you are using IE, and see if it behaves differently. I use firefox... :-\ Quote Link to comment https://forums.phpfreaks.com/topic/53517-problem-viewing-cookies/#findComment-264492 Share on other sites More sharing options...
DeathStar Posted May 30, 2007 Share Posted May 30, 2007 Try this: <? setcookie('super_password', 'hello'", time()+3600, '/'); echo "the cookie is ".$_COOKIE[super_password]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/53517-problem-viewing-cookies/#findComment-264493 Share on other sites More sharing options...
btherl Posted May 30, 2007 Share Posted May 30, 2007 Aha.. well try installing the live http headers extension, so you can monitor what is sent. http://livehttpheaders.mozdev.org/ Then at least you can be sure the cookie is being sent.. after that, it's a question of why you can't find it in php.. Quote Link to comment https://forums.phpfreaks.com/topic/53517-problem-viewing-cookies/#findComment-264504 Share on other sites More sharing options...
eyalros Posted May 30, 2007 Author Share Posted May 30, 2007 Aha.. well try installing the live http headers extension, so you can monitor what is sent. http://livehttpheaders.mozdev.org/ Then at least you can be sure the cookie is being sent.. after that, it's a question of why you can't find it in php.. Thanks! after I've installed it cookies started to work - but only in Firefox! not in IE - no matter what is the privacy level is - even if it's accepts all cookies! Quote Link to comment https://forums.phpfreaks.com/topic/53517-problem-viewing-cookies/#findComment-264513 Share on other sites More sharing options...
eyalros Posted May 31, 2007 Author Share Posted May 31, 2007 I found out something weird: IE accepts my cookie only if it's time being set to 0 like that: setcookie("name", "value", 0, "/"); I cannot put something like "time()+3600" - it's don't accepts it. Does somebody know how can I solve that problem? Quote Link to comment https://forums.phpfreaks.com/topic/53517-problem-viewing-cookies/#findComment-265542 Share on other sites More sharing options...
per1os Posted May 31, 2007 Share Posted May 31, 2007 Try this: <? setcookie('super_password', 'hello'", time()+3600, '/'); echo "the cookie is ".$_COOKIE['super_password']; ?> I do not think this would work due to the fact that you generally cannot access cookies until the next page. Are you trying to do this on Localhost, if yes let me know and I will post a tutorial for you. Quote Link to comment https://forums.phpfreaks.com/topic/53517-problem-viewing-cookies/#findComment-265562 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.