首页 > 代码库 > Cookie的用法

Cookie的用法

string strCookie="";//创建一个名为userHttpCookie userCookie=new HttpCookie("user");//value给单个Cookie值赋值userCookie.Value="http://www.mamicode.com/nihao";Response.Cookie.Add(userCookie);//取值HttpCookie userCookie=Request.Cookie["user"];strCookie=userCookie.Value;//在一个Cookie中储存多个信息,那也没有问题//values是获取单个cookie对象键值对的集合HttpCookie userCookie=new HttpCookie("user");userCookie.values.Add("nihao",txtName.value);userCookie.values.Add("nihao2",txtName2.value);Response.Cookie.Add(userCookie);//取值HttpCookie userCookie=Request.Cookie["user"];cookie1=userCookie.Values["nihao"];cookie2=userCookie.Values["nihao"];

  

Cookie的用法