how to declare a session variable in c# code example
Example: c# access session in class
public class MySession
{
private MySession()
{
Property1 = "default value";
}
public static MySession Current
{
get
{
MySession session =
(MySession)HttpContext.Current.Session["__MySession__"];
if (session == null)
{
session = new MySession();
HttpContext.Current.Session["__MySession__"] = session;
}
return session;
}
}
public string Property1 { get; set; }
public DateTime MyDate { get; set; }
public int LoginId { get; set; }
}