cookie的基本用法
2012-03-31 13:42
344 查看
写cookie
HttpCookie UserCookie = new HttpCookie("userName");
UserCookie["name"]=dr["user"].ToString();
UserCookie.Expires=DateTime.Now.AddDays(1);//这里设置要保存多长时间.
Response.Cookies.Add(UserCookie);
读取cookie
HttpCookie cookie=Request.Cookies["userName"];
string name=cookie.Values["name"];
清除cookie
HttpCookie cookie=Request.Cookies["userName"];
if(cookie!=null)
{
cookie.Expires=DateTime.Now.AddDays(-2);
Response.Cookies.Set(cookie);
}
HttpCookie UserCookie = new HttpCookie("userName");
UserCookie["name"]=dr["user"].ToString();
UserCookie.Expires=DateTime.Now.AddDays(1);//这里设置要保存多长时间.
Response.Cookies.Add(UserCookie);
读取cookie
HttpCookie cookie=Request.Cookies["userName"];
string name=cookie.Values["name"];
清除cookie
HttpCookie cookie=Request.Cookies["userName"];
if(cookie!=null)
{
cookie.Expires=DateTime.Now.AddDays(-2);
Response.Cookies.Set(cookie);
}
相关文章推荐
- js中cookie的基本用法
- cookie和session的基本用法小结
- jQuery访问浏览器本地存储cookie、localStorage和sessionStorage的基本用法
- .net中Cookie基本用法
- JavaScript中Cookie的基本用法
- cookie基本用法整理
- cookie的基本用法案例
- cookie基本用法
- Cookie ,Session的基本用法
- JS-Cookie的基本用法
- MySQL的mysqldump工具的基本用法
- 安卓好用的数据库LitePal的基本用法
- 安全测试工具AWVS基本用法
- NSData 基本用法
- Android中Menu的基本用法 .
- java中Property类的基本用法
- [置顶] Android开发之数据存储——SharedPreferences基础知识详解,饿补学会基本知识,开发者必会它的用法。
- UIWebView的基本用法
- vector基本用法
- 上机实验——Linux中Vi的基本用法