如何在代码后面的chek会话超时 [英] how to chek session timeout in code behind
问题描述
我已经创建了一个网站,聊天功能就在那里
i想要用户不注销
a条目应该进入数据库是否关闭浏览器或页面是iedal一段时间。
automaticalyy logout
i have create a website in that chat functionality is there
i want if a user do not logout
a entry should go in database whether he close browser or page is iedal for sometime.
automaticalyy logout
推荐答案
在会话中
指定会话可以保留的分钟数在服务器自动终止之前空闲。默认值为10分钟。 Session.Timeout没有硬编码限制。大多数Web管理员将此属性设置为8分钟。它不应设置为高于20分钟(特殊情况除外),因为每个打开的会话都保留在内存中。它也不应低于4分钟,因为客户很少在这段时间内回复,导致会话状态丢失。
In Session
Specifies the number of minutes that a session can remain idle before the server terminates it automatically. The default is 10 minutes. Session.Timeout has no hard-coded limit. Most Web administrators set this property to 8 minutes. It should not be set higher than 20 minutes (except in special cases) because every open session is holding onto memory. It should also not be set lower than 4 minutes because clients rarely respond within that time resulting in a loss of session state.
<configuration>
<system.web>
<sessionState timeout="20"></sessionState>
</system.web>
</configuration>
如果用户在超时期限内没有刷新或请求页面,则会话结束。
并检查会话是否为在MasterPage加载事件中为null
If the user does not refresh or request a page within the time-out period, the session ends.
And check if session is null in MasterPage load event
if(Session["UserID"]==null)
Response.Redirect("Login.aspx");
用户
User
HTML <meta> Tag
能够重新加载当前页面很有用,它通常不是人们想要的元刷新标签。要重定向到新页面,语法与重新加载当前页面几乎相同:
While being able to reload the current page is useful, it is not typically what people want from the meta refresh tag. To redirect to a new page, the syntax is nearly the same as reloading the current page:
<meta http-equiv="refresh" content="600">
content =600 - 这是浏览器重新加载当前页面之前的时间量(以秒为单位)。这次会话将重定向到登录页面in null
获取更多信息
redirect-meta-refresh.phtml [ ^ ]
这篇关于如何在代码后面的chek会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!