LearnFast.Ninja

How to access session variables from any class in ASP.NET C#

When you want to access the current session from C# class in ASP.NET you need to use the HttpContext class that contains the specific information about an individual HTTP request.

Main idea:
HttpContext.Current.Session["UserName"]

Example:
string User_Name = HttpContext.Current.Session["UserName"].ToString();

Tags

asp.net

session httpcontext