[Javascript] AJAX + Cookies

Matt Warden mwarden at gmail.com
Mon Jun 16 16:01:12 CDT 2008


On Mon, Jun 16, 2008 at 4:54 PM, Philip Thompson <philthathril at gmail.com> wrote:
> Matt, thanks for your prompt response. However, I'm not sure I follow.
> Is this what you mean...
>
> Document 1:
> Makes AJAX call to Document 2 that does stuff and updates the cookies
>
> Document 2:
> Updates the cookies and sets the new values and returns stuff to
> Document 1
>
> Are you saying that the new cookie values are only accessible by
> Document 1 at this point? If not, can you please elaborate?

No, the opposite. But let me change it slightly to be technically correct.

Make request to server with cookie A data, server returns document 1
Document 1 contains code that initiates a async call to server with
cookie B data, and server returns document 2

document 1 contains cookie A data
document 2 contains cookie A data except where cookie B data has same
name as cookie A data, in which case the value will be from cookie B

If you were then to reload document 1 (without sending any cookie
data), you would get the same result as which was sent to document 2.

The point is that the cookie data for a document is static after the
server response is made to send you that document, unless you
manipulate the cookie data directly with JavaScript.

-- 
Matt Warden
Cincinnati, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the Javascript mailing list