About Me

My photo
Dhaka, Bangladesh
I am B.S.C Engineer,CSE,SUST and Ex-Cadet of Mirzapur Cadet College.

Tuesday, July 15, 2008

Cookie based Session management

Setting cookie:

string email="redwan_choyon@yahoo.com";
HttpCookie myCookie = new HttpCookie("UserName");
myCookie.Value=email;
Response.Cookies.Add(myCookie);

Getting cookie:

if (Request.Cookies["UserName"] != null)
{
Label1.Text = Request.Cookies["UserName"].Value;
}
else
{
Label1.Text = "";
//Response.Redirect("login.aspx");

}