0

I need to create session variables in controller with data which is sent from the view, and I need to access those session variables in anywhere in my aplication

here is my code

controller

[HttpPost]
    public ActionResult AccessLogInData(Login userloginData)
    {
        string Id = userloginData.Id;
        string userName = userloginData.userName;
        string password = userloginData.password;
        string Designation = userloginData.Designation;
        string Supplier_Code = userloginData.Supplier_Code;
        string Distributor_Code = userloginData.Distributor_Code;
        string Staff_Code = userloginData.Staff_Code;

       //here I need create sessions
    }
user3840485
  • 4,735
  • 3
  • 20
  • 22
  • 1
    To add something to Session - `Session["YourKey"] = yourValue;` –  Sep 05 '14 at 00:53
  • @Stephen Muecke how can I access session, and do I need start session or something, please explain me little – user3840485 Sep 05 '14 at 00:57
  • 1
    To access it - `var value = Session["YourKey"] as yourValueType;`. To clear it - `Session["YourKey"] = null;` –  Sep 05 '14 at 01:02
  • Suggest you read the answers and comments to [this question](http://stackoverflow.com/questions/14138872/how-to-use-sessions-in-an-asp-net-mvc-4-application) –  Sep 05 '14 at 01:04
  • @ Stephen Muecke how can I clear whole session varables at once – user3840485 Sep 05 '14 at 01:08

0 Answers0