Get Current Session Value in JavaScript?
Another approach is in your chtml
<input type="hidden" id="hdnSession" data-value="@Request.RequestContext.HttpContext.Session['someKey']" />
and the script is
var sessionValue= $("#hdnSession").data('value');
or you may access directly by
jQuery(document).ready(function ($) {
var value = '@Request.RequestContext.HttpContext.Session["someKey"]';
});
The session is a server side thing, you cannot access it using jQuery.
You can write an Http handler (that will share the sessionid if any) and return the value from there using $.ajax
.