I would like to use session variables in my ASP.NET MVC application.
I already added the <sessionState> to my web.config , like this
<sessionState mode="InProc" cookieless="false" timeout="20"> </sessionState>
I get the session id in my url, for example if I use cookieless="true"
http://localhost:2967/%28S%28hcawmi55zoruuy453fbo3k55%29%29/RmdReqBankAccount
But I still cannot use session variables in my application.
I set such a variable in my login method:
Session["username"] = userName;
and I get it like this:
string user_id = (string)Session["username"];
I get an empty string when trying to get the values.
source share