save cookies and get cookies in system using asp.net

1. use Response.cookies[“cookiesname”][“keyname”] to save cookies
2. use  Request.cookies[“cookiesname”][“keyname”] to get cookies;

Eg.
Save cookies codingl
Response.Cookies["userinfo"]["username"] = tb_username.Text;
Response.Cookies["userinfo"]["planner"] = tb_planner.Text;
Response.Cookies["userinfo"].Expires = System.DateTime.Today.AddDays(10);
Get cookies coding
  assumption: there are two texbboxs username and planner. When user input the username, the planner will fill out the textbox automatically.
string oldstr = Request.Cookies["userinfo"]["username"];
   if (tb_username.Text==oldstr)
      tb_planner.Text = Request.Cookies["userinfo"]["planner"];


 

posted on 2008-01-04 21:33  飞天舞者  阅读(244)  评论(0编辑  收藏  举报

导航

For more information about me, feel free email to me winston.he@hotmail.com