Get Current Session Value in JavaScript?

后端 未结 11 1700
深忆病人
深忆病人 2021-02-05 01:10

I have a scenario where I open my web application in a browser but in two separate tabs.

In one tab I signed out from the application and as a result the all session val

11条回答
  •  半阙折子戏
    2021-02-05 01:52

    I am using C# mvc Application. I have created a session in the Controller class like this

    string description = accessDB.LookupSomeString(key, ImpDate);
    this.Session["description"] = description;    
    

    in the View, We access the session value and store it in a variable, like this (this is within an $.ajax, but I think it should work within any jquery)

    var Sessiondescription = '@Session["description"]';
    alert(Sessiondescription);
    

提交回复
热议问题