使用SessionState模式=像cookie一样的SQLServer
我试图通过浏览器关闭/重新打开来保留页面上的设置。目前该页面没有用户登录的概念。每次我关闭浏览器、重新打开浏览器并加载页面时,都会创建一个新的 SessionID。我想加载旧的 SessionID。这可能吗?我认为是这样,因为这就是保存它的全部意义,但在谷歌搜索了一下之后,我没有看到任何相关内容。
我尝试将超时设置为一年,但即使超时很长,它仍然会创建一个新的 SessionID。
谢谢!
I am trying to persist settings on a page through browser close/re-open. Currently the page has no concept of a user logging in. Every time I close the browser, re-open the browser, and load the page a new SessionID is created. I would like to load the old SessionID. Is this possible? I'd assume so since that's the entire point of saving it, but after Googling for a bit I didn't see anything on this.
I tried setting the timeout to a year, but even with a high timeout it still creates a new SessionID.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用持久性cookie。在 ASP.NET 中,当您发出 cookie 时,您可以设置
使
属性在未来的某个日期过期。这将在客户端浏览器上创建一个持久 cookie,即使用户再次关闭/重新打开浏览器,您也能够取回该值。因为我们生活在 2011 年,HTML5 正在敲响我们的大门(它甚至已经进入了一些家庭),所以值得研究一下 HTML5本地存储。
You could use persistent cookies. In ASP.NET when you emit a cookie you could set the
Expires
property to some date into the future. This will create a persistent cookie on the client browser and you will be able to fetch the value back even if the user closes/reopens the browser again.And because we live in 2011 and HTML5 is knocking on our doors (it has even entered inside some homes) it is worth looking into the HTML5 local storage.