简体   繁体   English

如何检查用户是否已使用Cookie登录?

[英]How to check if the user is already logged in or not using Cookie?

I want to know how can I detect if the user is already logged in or not? 我想知道如何检测用户是否已登录? using a cookie. 使用cookie。 I am not using any log-in control. 我没有使用任何登录控件。 I have a db which checks the ID and PWD. 我有一个数据库检查ID和PWD。 Also pls let me know if it can be done without using cookies. 如果可以在不使用cookie的情况下完成,请告诉我。 Any code or links will help. 任何代码或链接都会有所帮助。 web.config: web.config中:

  <authentication mode="Forms">
  <forms name="myForm" loginUrl="LogIn.aspx" path="/" defaultUrl="Home.aspx">
</forms>
  </authentication>
<authorization>
  <deny users="?"/>
   </authorization>

Thanks 谢谢

In asp.net using windows / forms authentication you can tell if the user is logged in via : 在使用Windows /窗体身份验证的asp.net中,您可以通过以下方式判断用户是否已登录:

<%
   Page.User.Identity.IsAuthenticated
%>

Forms Authentication is cookie based, but can be configured to not use cookies with the cookieless setting. 表单身份验证是基于cookie的,但可以配置为不使用cookie与cookieless设置。

How to fully setup forms authentication is not a quick answer but it is relatively easy to setup there are many HOW-TO's online. 如何完全设置表单身份验证不是一个快速的答案,但它相对容易设置有很多HOW-TO在线。 Here is a good one http://www.4guysfromrolla.com/webtech/110701-1.shtml 这是一个很好的http://www.4guysfromrolla.com/webtech/110701-1.shtml

MSDN : http://msdn.microsoft.com/en-us/library/aa480476.aspx MSDN: http//msdn.microsoft.com/en-us/library/aa480476.aspx

You can use Windows Authentication also which does not use cookies. 您也可以使用不使用cookie的Windows身份验证。

我用了:

HttpContext.Current.Request.IsAuthenticated

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

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