简体   繁体   English

如何自动登录用户

[英]how to auto login user

here is what i am trying to do:这是我想要做的:

  1. user logs in and check rember me.用户登录并检查记住我。
  2. user then closes the site.用户然后关闭该站点。
  3. next time the user visits the sites he is auto logged in withoutre-entring his user or password下次用户访问网站时,他会自动登录,无需重新输入用户名或密码

thanks谢谢

using asp.net 3.5.使用 asp.net 3.5。 using forms authentication使用 forms 认证

When you are calling FormsAuthentication.SetAuthCookie() , you can set the second parameter to true to make the cookie persist for a very long time.当您调用FormsAuthentication.SetAuthCookie()时,您可以将第二个参数设置为 true 以使 cookie 保持很长时间。

Depending on your authentication model, I have a manual authentication process, by that i mean i Have a site whos entire authentication model has been coded from the ground up to suite the website.根据您的身份验证 model,我有一个手动身份验证过程,我的意思是我有一个站点,其整个身份验证 model 已经从头开始编码以适应该网站。
No built in .net is used.没有使用内置 .net。

We hold an auto login feature in our cookie.我们在 cookie 中拥有自动登录功能。 The way this is done is by adding the login username and password to the cookie, but all key names and values in the cookie are encrypted with triple des encryption.这样做的方法是将登录用户名和密码添加到 cookie 中,但 cookie 中的所有键名和值都使用三重 des 加密进行加密。 So in the unlikely event the cookie is decrypted, they then face a triple des encryption to get the user credentials.因此,万一 cookie 被解密,他们将面临三重加密以获取用户凭据。

We have a handler that checks if the user is logged in on each request, various flags in the session are set to signify whats happening.我们有一个处理程序来检查用户是否在每个请求中登录,session 中的各种标志被设置为表示发生了什么。 eg you first land on the site, the handler checks for cookie support, if not provided a flag in the session signifies client doesnt support cookies and no further attempts are made.例如,您首先登陆该站点,处理程序检查 cookie 支持,如果未在 session 中提供标志,则表示客户端不支持 cookies 并且不再进行尝试。 If it does support cookies the cookie is read, and if auto login is checked the credentials from the cookie are used to login.如果它确实支持 cookies,则读取 cookie,如果选中自动登录,则使用 cookie 中的凭据进行登录。

It is easier to use the built in .net authentication model, but for ultimate control, DIY.使用内置的 .net 认证 model 更容易,但为了最终控制,DIY。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM