Reputation:
I was wondering if it's possible to get the session id of a session with jQuery ? And if so, how do I do that, can't seem to find it on jquery.com
Upvotes: 3
Views: 4895
Reputation: 15217
session ID is stored either in cookies or in query string (depending on browser capabilites or asp.net configuration). Find where your session id is and read it from there
Upvotes: 2
Reputation: 337550
You cannot do it in jQuery alone as it is client-side only and cannot talk to the server to get the sessionID.
The workaround is to create a webservice which returns the session id in XML/JSON format, which you can call from an AJAX request in jQuery.
Something like this:
$.ajax({
url: "/mywebservice.asmx",
dataType: "json",
success: function(data) {
var sessionId = data.sessionId; // This would be determined by your server-side implementation
// do something with the sessionId...
}
});
Upvotes: 1