Friday, August 18, 2006

Wraping Session to Gobal Session Class


using System;
using System.Web;

namespace MyApp
{
public class SessionGlobal
{

private const string _AccountNo = "_AccountNo";

// Set to default Values
public static void Clear()
{

HttpContext.Current.Session[_AccountNo]="";

}

private static string getSessionVar(string key)
{
if(HttpContext.Current.Session[key]!=null)
return HttpContext.Current.
Session[key].ToString();
else
return "";

}

public static string AccountNo
{
get
{
return getSessionVar(_AccountNo);
}
set
{
HttpContext.Current.Session[_AccountNo]=value;
}
}

public static string UserID
{
get
{
return HttpContext.Current.
Request.ServerVariables["AUTH_USER"];
}

}

}
}

No comments: