I'm writing a jQuery Mobile app that makes several AJAX requests to a few different IHttpHandler
classes on my server. The handlers all return JSON or JSONP, and include the context.Session.SessionID
in the JSON, for debugging purposes. I make one request to the first handler, and get back session ID "2jysbehwyxlne0knatltcb2z". I make another request to a different handler, and get back session ID "qy3v251fxrxesbgqeobqvaza". This is within a few seconds of each other. What is going on? I would expect the session ID to be the same until the session expires after an extended time.
When I open the requests in their own tabs, as opposed to via AJAX in the same tab, I get the same session ID back. So for my request to authenticate and then my other request to retrieve data, when these requests happen as AJAX requests in a page, the session IDs are different. When I browse the Network tab in Chrome's console and right-click, Open Link in New Tab each of the requests, they function as expected, having the same session ID.
I am running the jQuery Mobile application on http://localhost
, and making requests to handlers at https://localhost
, if this matters. All of my handlers implement IRequiresSessionState
. This question looks the same as mine, and its only answer is to implement IRequiresSessionState
, which I'm doing already.
Edit: this question might be related, but I'm observing this behavior in Chrome.
Edit: I'm using jQuery's getJSON
function to make the AJAX request. This question about getJSON
and cookies might be relevant.