gpt4 book ai didi

C# - WebForms - 可以复制 HttpContext.Current.SessionID 吗?

转载 作者:行者123 更新时间:2023-11-30 13:40:47 25 4
gpt4 key购买 nike

每当用户登录我的网站时,我都会将 HttpContext.Current.SessionID 存储在我的用户日志表中。我想确定这可以重复吗?如果是,我想让该列在数据库中唯一。如果它可以复制,那么从 session 中获得的任何东西都将是唯一的,并且将来永远不会像 GUID 那样重新生成?

最佳答案

HttpContext.Current.SessionID 对于当前 session 集 将是唯一的 - 也就是说,每个 session ID 在事件时都是唯一的。但是,一旦 session 过期,就无法保证新 session 不会具有相同的 ID。如果是这种情况,任何持久数据(基于 session ID)现在都将引用不同的 session 。

另请注意 MSDN page 中的以下备注.

The SessionID value is randomly generated by ASP.NET and stored in a non-expiring session cookie in the browser. The SessionID value is then sent in a cookie with each request to the ASP.NET application.

但是,如果 cookie 被清除, session 将重新启动。

The SessionID is sent between the server and the browser in clear text, either in a cookie or in the URL. As a result, an unwanted source could gain access to the session of another user by obtaining the SessionID value and including it in requests to the server. If you are storing private or sensitive information in session state, it is recommended that you use SSL to encrypt any communication between the browser and server that includes the SessionID.

关于C# - WebForms - 可以复制 HttpContext.Current.SessionID 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7004831/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com