using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for MySession
/// </summary>
public class MySession
{
// private constructor
private MySession() { }
// Gets the current session.
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 static void Clear()
{
MySession session =
(MySession)HttpContext.Current.Session["__MySession__"];
if (session != null)
{
HttpContext.Current.Session.Remove("__MySession__");
}
}
// **** add your session properties here, e.g like this:
public User User { get; set; }
}
No comments:
Post a Comment