Jump to content

Problem with Cookie detection


ProblemHelpPlease
 Share

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 Edited by samgenius
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...