0

单击“记住我”复选框时,我想将登录名和密码存储在 cookie 中。我的login.cshtml样子input type="text"id="loginName"input type="password" id = "password"。我怎样才能做到这一点?

4

1 回答 1

1

尝试这个

   // create a cookie
        HttpCookie loginName = new HttpCookie("loginName", model.LoginName);
        loginName.Expires = DateTime.Today.AddMonths(12);
        Response.Cookies.Add(loginName);

       HttpCookie password= new HttpCookie("password", model.Password);
        password.Expires = DateTime.Today.AddMonths(12);
        Response.Cookies.Add(password);
于 2013-09-03T05:25:28.120 回答