【转】创建COOKIE

记录COOKIE
       HttpCookie username = new HttpCookie("username");
        HttpCookie autolog = new HttpCookie("autologon");
        username.Value = TextBox1.Text;
        autolog.Value = CheckBox1.Checked.ToString();
        //保存一年
        username.Expires = DateTime.Today.AddYears(1);
        autolog.Expires = DateTime.Today.AddYears(1);
        Response.Cookies.Add(username);
        Response.Cookies.Add(autolog);

在FORM_LOAD中读取COOKIE
        if (Request.Cookies["username"]!= null)
        {
            TextBox1.Text = Request.Cookies["username"].Value;
            CheckBox1.Checked = bool.Parse(Request.Cookies["autologon"].Value);
        }

原文地址:https://www.cnblogs.com/xiaolinshushu/p/2776708.html