Jump to content

Problem Viewing Cookies


eyalros

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/53517-problem-viewing-cookies/
Share on other sites

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!

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.