.NET Session - Persist session, even when the user closes the browser

前端 未结 2 1047
一个人的身影
一个人的身影 2020-12-17 05:07

We use .net framework 3.5 and C#.

We have a site that requires the user to log in. So we use a database to check if the login / password is correct.

Then we

2条回答
  •  一个人的身影
    2020-12-17 05:50

    You shouldn't mix terms, remember that you have both authentication cookie and session state in asp.net.

    You appear to be looking for a persistent auth cookie. to have a persistent auth cookie try

    FormsAuthentication.SetAuthCookie("xxx",true); 
    

    http://msdn.microsoft.com/en-us/library/twk5762b(v=vs.90).aspx

    passing true will allow the authentication cookie to survive browser restarts. also you should consider your timeout values for forms authentication and session in your web.config

    
            
            
        
    
    
    

提交回复
热议问题