将用户数据存储在内存中

发布于 2024-11-07 13:50:35 字数 264 浏览 0 评论 0原文

我对使用表单身份验证相当陌生,并且正在尝试了解这一切是如何工作的。基本上,我想要做的是存储一些与 FormsAuthentication 票证相关的用户数据(从我的 ldap 服务器返回的数据);但是,我不想实际将此数据存储在 cookie 中,因为它可能是相当大量的数据。是否可以以某种方式将此信息存储在服务器的内存中,但将其与票证紧密相关,以便如果用户超时或注销,数据也会被破坏。我意识到我可以使用会话变量来执行此操作,但这似乎很尴尬,因为如果用户注销,我必须手动清理会话变量。这可能吗?或者这样做是否有意义?

I'm fairly new to using Forms Authentication and am trying to wrap my head around how this all works. Basically, what I'd like to be able to do is store some user data that is associated with the FormsAuthentication ticket (data that comes back from my ldap server); however, I don't want to actually store this data in the cookie as it could be a rather large amount of data. Is it somehow possible to store this information in memory on the server, but keep it strongly tied to the ticket so that if the user times out or is logged out the data is destroyed as well. I realize I could use session variables to do this, but this seems awkward as I'd have to manually clean up the session variables if the user logs out. Is this possible or does this even make sense to do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若水般的淡然安静女子 2024-11-14 13:50:35

为什么必须手动清理会话?会话字典的全部目的是让您能够准确地执行您想要执行的操作:将一些已知数据与用户当前的浏览器会话相关联。当用户的浏览器会话由于某种原因结束时,HttpApplication 及其会话将被孤立并被垃圾回收。因此,我只需将您的 LDAP 数据放入一个或一组相同密钥下的会话中,然后就不用管它了。

Why would you have to manually clean up a Session? The entire purpose of the Session dictionary is to allow you to do exactly what you want to do here: associate some known data with the user's current browser session. When the user's browser session ends for whatever reason, the HttpApplication and its Session are orphaned and GCed. So, I would just put your LDAP data into Session under a key, or set of same, and forget about it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文