Assign session value using javascript

后端 未结 4 1229
一生所求
一生所求 2020-12-19 21:36

Is there any way to assign session value using javascript

i can retrive the value from session but assigning is not working

var TempSession = \'<%         


        
4条回答
  •  清歌不尽
    2020-12-19 22:21

    If you're talking about server-side session then it really depends on the server-side.

    It should assign you a session id, usually through a cookie....
    That means you could for example make an ajax request to a designated url in your server, specifying the required session id. That ajax request would then assign the session through a cookie.

    Another idea would be to actively create a cookie (again, if server supports that) on the client-side with JavaScript with specific session id, i.e

    $.cookie("SESSION", "session-id"); // Using jQuery
    

    Although I've never tried that before.
    Note above that the cookie's name depends on your server technology (Tomcat is JSESSIONID by default [link], ASP.NET is ASP.NET_SessionId [link], under "Note").

提交回复
热议问题