---恢复内容开始---

cookie的简单使用

 1 public partial class Login:System.Web.UI.pag
 2 {
 3     public string LoginUserName{get;set;}
 4     protected void Page_Load(object sendet,EventArgs e)
 5     {
 6          if(IsPostBack)
 7          {
 8                string userName=Request.Form["txtName"];
 9                Response.Cookies["userName"].Value=Server.UrlEncode(UserName);
10                Response.Cookies["userName"].Expires=DateTime.Now.AddDays(7);
11          }
12          else
13          {
14               string name=Server.urlDecode(Request.Cookies["userName"].Value);
15               LoginUserName=name;
16               Response.Cookies["userName"].Value=Server.urlEncode(name);
17               Response.Cookies["userName"].Expires=DateTime.Now.AddDays(7);//设置过期时间
18          }
19     }
20 }
View Code

相关文章:

  • 2021-12-29
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-11
  • 2022-12-23
  • 2021-08-04
  • 2021-07-09
  • 2021-09-01
相关资源
相似解决方案