Jump to content

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

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...  :-\

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..

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.