https://www.cnblogs.com/Hmd528/p/10695156.html

 

if (lm.RememberMe)
                    {
                        HttpCookie hc = new HttpCookie("UserInfo");
                        //在cookie对象中保存用户名和密码
                        hc["UserName"] = lm.UserName;
                        hc["UserPwd"] = lm.Password;
                        //设置过期时间
                        hc.Expires = DateTime.Now.AddDays(2);
                        //保存到客户端
                        Response.Cookies.Add(hc);
                    }
                    else
                    {

                        HttpCookie hc = new HttpCookie("UserInfo");
                        //判断hc是否空值
                        if (hc != null)
                        {
                            //设置过期时间
                            hc.Expires = DateTime.Now.AddDays(-1);
                            //保存到客户端
                            Response.Cookies.Add(hc);
                        }
                    }

相关文章:

  • 2021-07-03
  • 2021-09-30
  • 2021-08-05
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案