问题描述
当有人登录到我的应用程序,他们选中了记住我复选框,我设置了 createPersistentCookie = TRUE
,这样,当他们回来,他们并不需要再次登录。但是,偶尔,我需要使用 FormsAuthentication.SetAuthCookie(NewUserName,[真/假])
让我怎么知道他们最初设置的 createPersistentCookie
来真的还是假的,所以我可以保持相同的,因为它是当他们登录?
When someone logs into my application and they checked the "Remember Me" checkbox, I set the createPersistentCookie = true
so that when they come back they don't need to log in again. However, occassionally, I need to use the FormsAuthentication.SetAuthCookie(NewUserName, [true/false])
so how do I know if they originally set the createPersistentCookie
to true or not so I can keep it the same as it was when they logged in?
推荐答案
我相信当你解密,你应该用的FormsAuthenticationTicket
这留下那么你就可以查询该cookie IsPersistent
属性。
I believe when you decrypt the cookie you should be left with a FormsAuthenticationTicket
which you can then query the IsPersistent
property.
要解密:
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value);
参考:
这篇关于我如何检查和QUOT; createPersistentCookie"在ASP.NET窗体身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!