Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookies passed in an AJAX get request

Status
Not open for further replies.

BabyJeffy

Programmer
Sep 10, 2003
4,189
GB
I've been working on some code and wanted to read the cookie collection (server-side) on an AJAX get request. I discovered that the cookie collection was not present (whereas it is present if the same page is visited manually).

I've yet to take some time to look into this, but wondered if anyone had already had any experience with reading cookies server-side via an AJAX get request?

We're using spring 2.0 on tomcat in our development environment (if it makes any difference).

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Jeff,

I am not much of an expert on this, but...

Are you expecting to get back cookies that have been placed by a server, or on the client side by the JavaScript? Is the client side IE or some other browser? Is the AJAX request going back to the same domain from which the page came?

Tom Morrison
 
Thanks for the reply, Tom.

I'm developing on Firefox under Windows - and whilst I haven't specifically tested under IE, I require the cookies regardless of the (modern) browser.

I'm setting the initial cookie server-side (as part of a login) and I'm testing it server-side later on when I get an AJAX request (I'm in the same domain - localhost). The cookie is available if I request the JSP within the browser directly... and I can access it on the page using Javascript no problem... it's just when I'm doing the AJAX request that they are not visible (server-side).

I've currently settled on passing an encrypted token as part of the AJAX request - and this will certainly do the trick for the moment (the final solution will be behind a load balancer and as such I cannot rely on sessions for this).

With the weekend on the horizon, I'll set up a test harness at home and sniff the transaction to see. I'll post my findings for whoever googles this next [smile]

Chers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Jeff,

Our BIS product uses a session cookie and so far we have not had anyone report that AJAX requests don't get reconnected to the correct session. I know some are doing things that would not work if this were not happening, e.g. progress reporting on long running processes.

I will be interested in what you determine.

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top