Msg#: 4458151 posted 3:03 pm on May 26, 2012 (gmt 0)
I'm using the following code to set a cookie:
So when the user clicks the "Accept this cookie" link it will set the cookie and close the div. If the user comes back to the page then it checks if that cookie exists and then doesn't show the link if it does exist.
The problem I have is that I have this in the header of my site and if I visit the homepage directly the cookie sets the path as "/" and so further pages do not show the "Accept" cookie link. If however
If however I navigate to a page off of the root i.e. /about then it will set the cookie but then going back to the homepage the "Accept" link remains and I have to click it again.
Msg#: 4458151 posted 4:47 pm on May 29, 2012 (gmt 0)
Well that's not why it does that. A cookie is set in the browser and can't be read until the next page load because it's a single direction communication. You can't set it and read it at the same time.
You're probably going to need to do a location reload/redirect to the same page after setting a cookie.