Cookie 获取,设置的简短代码
2010-04-04 12:31
387 查看
代码
public string GetCookie(string cookie)
{
if (Request.Cookies[cookie] != null)
return Request.Cookies[cookie].Value;
return string.Empty;
}
public void SetCookie(string cookieName, string cookieValue, int expireDate)
{
HttpCookie cookie = new HttpCookie(cookieName);
cookie.Expires = DateTime.Now.AddDays(expireDate);
cookie.Value = cookieValue;
Response.Cookies.Add(cookie);
}
public string GetCookie(string cookie)
{
if (Request.Cookies[cookie] != null)
return Request.Cookies[cookie].Value;
return string.Empty;
}
public void SetCookie(string cookieName, string cookieValue, int expireDate)
{
HttpCookie cookie = new HttpCookie(cookieName);
cookie.Expires = DateTime.Now.AddDays(expireDate);
cookie.Value = cookieValue;
Response.Cookies.Add(cookie);
}
相关文章推荐
- 【JavaScript代码实现四】获取和设置 cookie
- c#代码获取web.config配置文件里面设置的 <compilation debug="true"节点的debug值
- 做了CDN获取用户真实IP的函数代码(PHP与Asp设置方式)
- httpclient4.5获取和设置cookie
- cookie实时存储 设置cookie值 获取cookie值 删除cookie
- 应用js设置cookie于获取cookie
- c#设置或者获取byte(字节、8位二进制整数)某位的的值的代码
- javascript设置和获取cookie的方法实例详解
- 网络各通信 - 获取和设置 Cookie
- vue中设置、获取、删除cookie的方法
- 在C#应用程序中获取和设置IE浏览器Cookie
- 获取屏幕高宽,在代码中设置控件大小的方法
- js中的cookie的设置获取和检查
- cookie获取游览器的上次访问时间的代码
- 设置cookie指定时间失效(实例代码)
- js中cookie设置与获取
- 基于visual c++之windows核心编程代码分析(21)获取和设置环境变量
- .NET中的Cookie设置HttpOnly,可以防止JS获取Cookie的值
- js获取光标位置和设置文本框光标位置示例代码
- 设置和读取cookie的javascript代码