Purpose - Accessing session,cookies in your class files.
say,
I am using one global function that check that wether user session is
expired or not in that case i have created one class file. Now to access
values of session in the class file i can call the function like
cls_Check_Sessoin objSession=new cls_Check_Sessoin();
protected void Page_Load(object sender, EventArgs e)
{
if(objSession.IsAuthenticated(this.Context))
{
some porocess code;
}
else
{
Response.Redirect("Login.aspx");// will be called if session is expired
}
}
//-------------------In my class file i have function that check the page session
//--values like
public static bool IsAuthenticated(HttpContext context)
{
if (context.Session["User"] == null)
{
return false;
}
else
{
return true;
}
}
No comments:
Post a Comment