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;
}
});
source
share