Please refer below article
Not possible to assign session values directly through javascript.
I found alternative ways. Call the code behind function and assign the session values.
Javascript Function:
function InitializeRequest(path) {
// call server side method
PageMethods.SetDownloadPath(path);
}
Code Behind Function:
[System.Web.Services.WebMethod]
public static string SetDownloadPath(string strpath)
{
Page objp = new Page();
objp.Session["strDwnPath"] = strpath;
return strpath;
}
Must enable page methods set to true
<asp:ScriptManager EnablePageMethods="true" ID="MainSM" runat="server" ScriptMode="Release" LoadScriptsBeforeUI="true"></asp:ScriptManager>