title: How to use Session Variable in MVC
body: <p>I have declared Session variable in "Global.asax" file as,</p>
  
  <pre><code>protected void Application_Start()
          {
              AreaRegistration.RegisterAllAreas();
              FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
              RouteConfig.RegisterRoutes(RouteTable.Routes);
              BundleConfig.RegisterBundles(BundleTable.Bundles);
              int temp=4;
              HttpContext.Current.Session.Add("_SessionCompany",temp);
          }
  </code></pre>
  
  <p>And want to use this Session Variable into My Controller's action as,</p>
  
  <pre><code> public ActionResult Index()
          {
              var test = this.Session["_SessionCompany"];
              return View();
          }
  </code></pre>
  
  <p>But I am Getting Exception While accessing the Session Variable.
  Please help me on this that How can I access the Session Variable into my controller's Action.</p>
  
  <p>I am getting an Exception like 
  <code>"Object Reference not set to an Insatance of an object"</code>
  in <code>Application_Start</code> in Global.asax  on line</p>
  
  <pre><code>HttpContext.Current.Session.Add("_SessionCompany",temp);
  </code></pre>