• Twitter
  • Facebook
  • Google+
  • Instagram
  • Youtube

Wednesday, August 29, 2007

Read-Write a Cookie in Asp.Net

Read-Write a Cookie
==================

Write Cookie
----------------

HttpCookie myCookie = new HttpCookie("UserSettings");
myCookie["Font"] = "Arial";
myCookie["Color"] = "Blue";
myCookie.Expires = DateTime.Now.AddDays(1); // Set the Cookie Expiration Time
Response.Cookies.Add(myCookie);


Read Cookie

---------------
if (Request.Cookies["UserSettings"] != null)
{
string userSettings;
if (Request.Cookies["UserSettings"]["Font"] != null)
{
userSettings = Request.Cookies["UserSettings"]["Font"];
}
}

0 comments:

Contact

Get in touch with me


Adress/Street

12 Street West Victoria 1234 Australia

Phone number

+(12) 3456 789

Website

www.johnsmith.com