[Javascript] AJAX + Cookies
Philip Thompson
philthathril at gmail.com
Mon Jun 16 15:36:32 CDT 2008
Hi all.
I've been hitting my head against the wall for a while now. I've
gotten a few hits from Google, but nothing has really answered my
question:
After updating the value of a cookie during an AJAX request, can that
value be immediately accessed via the cookie (w/o a new request)?
[js]
alert(readCookie('mycookie'));
updateCookie('mycookie', 'newValue');
alert(readCookie('mycookie'));
[/js]
The output for this *should* be:
oldValue
newValue
However, I'm getting:
oldValue
oldValue
Now, I'm making the request via PHP. I'm echo'ing the javascript to
update the cookie. I know this can be set in PHP via the setcookie()
function, but the new value of the cookie is unavailable until the
next request. Well, I'm greedy and I want it now!
Any thoughts? Is this possible to have that cookie accessible when
immediately set/same request?
Thanks,
~Philip
More information about the Javascript
mailing list