想要无限制的会话超时,直到我点击退出 [英] Want unlimited session timeout untill I click logout

查看:86
本文介绍了想要无限制的会话超时,直到我点击退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的网站设置无限制的会话超时,但是它会在6分钟内过期。



在下一页加载事件(成功登录后)我有添加此代码,此代码是否影响会话到期之前



HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);

HttpContext.Current.Response.Cache.SetNoServerCaching();

HttpContext.Current.Response.Cache.SetNoStore();



< b>我尝试过:



1.更改Web.config会话超时变量。

I want To set unlimited session timeout for my website, but its getting expired in 6 Minutes.

On Next Page Load Event (After Sucessfull Login) I have Added this code,does this code affects session to expire before

HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoServerCaching();
HttpContext.Current.Response.Cache.SetNoStore();

What I have tried:

1. Changing Web.config Session Timeout Variable.

推荐答案

你不能设置无限制的会话超时,但你可以在这里设置一个非常高的数字:



You can't set an unlimited session timeout, but you can set a really high number here:

<system.web>
    <sessionState timeout="60000" />
</system.web>


如果您希望人们长时间登录(甚至无限期登录),请不要使用会话显示有人登录,改为使用cookie。
If you want people to be logged in for a long time (even indefinitely) then don't use the Session to show someone is logged in, use cookies instead.


John说的是真的,但是......请注意,有些系统会忽略延长会话超时的请求,因为每个Session都需要服务器资源,他们花钱。如果您的会话已从默认的20分钟缩短为6分钟,您可能会发现您的请求被忽略。

您设置超时的时间越长,您将使用的资源就越多 - 并且请记住,用户不会经常退出或以其他方式表示他们要离开您的网站。



相反,我建议你最好使用Cookies它们存储在客户端而不是会话中。
What John says is true, but...be aware that some systems ignore requests to lengthen the Session timeout because each Session takes server resources, and they cost money. If your session has already been reduced from the default 20 minutes to 6, you are likely to find that your request is ignored.
The longer you set your timeout, the more resources you will use - and do bear in mind that users do not often log out or otherwise signal that they are leaving your site.

Instead, I'd suggest that you might be better off using Cookies which are stored at the client end instead of the Session at all.


这篇关于想要无限制的会话超时,直到我点击退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆