猿问

ASP里怎样写一段用cookies记住登录用户的用户名和密码的代码呢?

ASP里怎样写一段用cookies记住登录用户的用户名和密码的代码呢?


白板的微信
浏览 461回答 3
3回答

12345678_0001

在登录框增加一个记住密码按钮:&nbsp;记住密码:<input value="1" type="checkbox" name="checkbox"<% If Request.Cookies("OTRememberMeCookie") = "1" Then&nbsp;&nbsp; Response.Write "CHECKED"&nbsp;&nbsp; Else&nbsp;&nbsp; Response.Write ""&nbsp;&nbsp; End If %>><input type="hidden" name="action" value="true"><input type="hidden" name="postion" value="<%=postion%>">&nbsp;在提交登录请求时增加以下处理代码,将用户名和密码写入cookie:<%&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;If Request.form("checkbox") ="1" Then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Cookies("OTPasswordCookie") = Request.Form("Password")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Cookies("OTRememberMeCookie") = "1"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Cookies("OTPasswordCookie").expires = Date+365&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Cookies("OTRememberMeCookie").expires = Date+365&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Cookies("OTRememberMeCookie") =""&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Cookies("OTPasswordCookie") = ""&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If&nbsp;%>

潇潇雨雨

在用户登录成功后添加下面的代码:Response.Cookies("UserCookie")("User")=xxxResponse.Cookies("UserCookie")("Password")=md5(pwd, 32)Response.Cookies("UserCookie").Expires=Date+cookies失效时间密码最好加密。在网站首页添加这样的代码:strUsername=Request.Cookies("UserCookie")("User")strPassword=Request.Cookies("UserCookie")("Password")验证这个cookies里取得的用户和密码是否正确,如果正确,就不用登录了。&nbsp;

慕森王

Response.Cookies("Username")=用户名Response.Cookies("Password")=密码这样设然后这样读:Request.Cookies("Username")Request.Cookies("Username")
随时随地看视频慕课网APP
我要回答