Forum Moderators: coopster

Message Too Old, No Replies

Server can not see cookie until after second reload/refresh?

Any way to have the server see a cookie's new value on the first reload?

         

JAB Creations

10:33 pm on Jan 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm sending the code that displays messages only when the server does not see a cookie. However unlike ASP PHP does not see a cookie until the second reload. This would have the code and message appear after the user has made a choice and I'd have to make the page reload so the server sees the cookie (on the second reload) and then does not send the code/message on the third load, but I want to avoid this. What is this issue? How can I get around it?

John

Key_Master

10:40 pm on Jan 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can set cookies in the server headers.

JAB Creations

11:27 pm on Jan 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure what you mean.

JAB Creations

12:21 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I figured it out! I was using "$HTTP_COOKIE_VARS" instead of "$_COOKIE" to read the cookie.

Here is an example for others to play around with...

<?php
echo $_COOKIE[example];
?>
<br />
<a href="#" onmousedown="document.cookie='example=1;path=/;time()+314496000;'" onmouseup="window.location.href=window.location.href">1</a> - <a href="#" onmousedown="document.cookie='example=2;path=/;time()+314496000;'" onmouseup="window.location.href=window.location.href">2</a>

John