7*24小时应急电话:15927160396
首页 新闻资讯 技术文章
Asp.net Cookies用法

创建Cookies

  public void UserCookies()
  {
   if(Request.Browser.Cookies == true)
   {
    if(Request.Cookies["UserLogin"]==null)
    {
     HttpCookie UserCookie=new HttpCookie("UserLogin",DateTime.Now.ToString());
     UserCookie.Value=Txt_Uname.Text;
     UserCookie.Expires = DateTime.Now.AddDays(1);
     Response.Cookies.Add(UserCookie);
     Request.Cookies.Set(UserCookie);
    
    }


   }
  }

 

退出

   if(HttpContext.Current.Request.Cookies["UserLogin"]!=null)
   {
    HttpCookie UserCookie= Request.Cookies["UserLogin"];
    UserCookie.Expires=DateTime.Now.AddDays(-1);
    HttpContext.Current.Response.Cookies.Add(UserCookie);
   }

 

判断Cookies是否为空

if(Request.Cookies["adminlogin"]==null)

{

  ....

}


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/liezuiwang/archive/2008/12/20/3558164.aspx

版权所有:武汉网福互联科技有限公司    鄂ICP备09022096号
业务QQ:23444550 客服QQ:267052100 电邮:23444550@qq.com  

鄂公网安备 42010602000905号

手机站二维码