views:

251

answers:

1

I'd like to use session variables in my ASP.NET MVC application.

I already added the <sessionState> tag in my web.config file like this

<sessionState mode="InProc" cookieless="false" timeout="20">
    </sessionState>

I get a session ID in my url like this if I use cookieless="true"

http://localhost:2967/%28S%28hcawmi55zoruuy453fbo3k55%29%29/RmdReqBankAccount

But I still can't use session variables in my application.

I set the variable like this in my login method:

Session["username"] = userName;

and I retrieve it like this

string user_id = (string)Session["username"];

I get an empty string when trying to retrieve values.

A: 

Fixed , it seems I got the wrong location when writing the set session variables.

Erwin