StatCounter

View My Stats

Tuesday, February 10, 2009

Creating a Cookie in ASP.NET

Creating a Cookie  in ASP.NET

#region Creating Cookies
HttpCookie JayaCookie = Request.Cookies["CookieExample"];
if (HttpContext.Current.Request.Cookies["CookieExample"].Value == null)
{
HttpContext.Current.Response.Cookies["CookieExample"].Value = Session.SessionID;
HttpContext.Current.Response.Cookies["CookieExample"].Expires = DateTime.Now.AddYears(30);
}
#endregion


For the above Example the cookie name is "CookieExample".I assigned the SessionID value to the cookie

No comments: