Jump to content

Problem with Cookie detection


ProblemHelpPlease

Recommended Posts

I am using PHP to set a cookie and have a problem with detecting the cookie afterwards.In the script I check if cookie exsits with if(isset($_COOKIE["abc"]))if it does then I make a change to the expiry dateif it doesnt then I create a cookie with setcookie....I then check again to see if the cookie now exists and at this point the check says it doesnt exists and therefore displays my "please enable cookies message".I know that the setcookie works because if I reload the page the script detects the cookie correctly and no longer displays the message.Is this something to do with server side and client side and when the cookie is actually created or is it something else

Link to comment
Share on other sites

I don't know if this is your situation, butremember that the $_COOKIE array is populated when your script begins to run. It is not dynamic. Updates to cookie data do not show in the $_COOKIE array until the next time the script runs. The solution is simply to build in another test condition for the situations where you are setting the cookie.

Link to comment
Share on other sites

I am using PHP to set a cookie and have a problem with detecting the cookie afterwards.In the script I check if cookie exsits with if(isset($_COOKIE["abc"]))if it does then I make a change to the expiry dateif it doesnt then I create a cookie with setcookie....I then check again to see if the cookie now exists and at this point the check says it doesnt exists and therefore displays my "please enable cookies message".I know that the setcookie works because if I reload the page the script detects the cookie correctly and no longer displays the message.Is this something to do with server side and client side and when the cookie is actually created or is it something else
Cookies always give a problem when it is call after <!DOCTYPE Always Call Cookie & Header before <!DOCTYPE called because COOKIE Will set before HTML Request to the browser
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...