Get ASP.NET Session ID using jQuery

I was wondering if it is possible to get the session id of a session using jQuery? And if so, how can I do this, can't find it on jquery.com

+3
source share
2 answers

You cannot do this only in jQuery, since it is only on the client side and cannot talk to the server to get sessionID.

The workaround is to create a web service that returns a session identifier in XML / JSON format that you can call from an AJAX request in jQuery.

Something like that:

$.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...
    }
});
+1
source

cookie, ( asp.net). , .

+2

All Articles