parliament
parliament

Reputation: 22934

HttpContext.Session garuanteed not null after setting?

If I do something as follows:

 public ActionResult Login(String Username,String ClientCode)
    {

        HttpContext.Session["clientcode"] = ClientCode;
        HttpContext.Session["security"] = Repository.GetSomething(HttpContext.Session["clientcode"].ToString());
    }

Is HttpContext.Session["clientcode]".ToString() garuanteed to return the value that was just passed in or does it have similar behavior to cookie where this would be unacceptable as the cookie is not garuanteed to still be there even a split second after setting it?

Upvotes: 0

Views: 123

Answers (1)

360Airwalk
360Airwalk

Reputation: 2207

the value will be lost as soon as the AppDomain resets or the user session times out. so, in theory, you have no guarantee.

but why would you not wanna use "ClientCode" in the second line of your example?

Upvotes: 1

Related Questions