关于会话破坏 [英] about session destroy

查看:84
本文介绍了关于会话破坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户闲置15分钟,我将尝试破坏会话.
销毁用户后,应该像您注销一样得到味精.
之后,他应该自动重定向到登录页面.
请任何人都可以提供帮助.
plz plz
它的紧迫性

i am trying to destroy session if user is idel for 15 min.
after destroying user should get msg like you are logdout.
after that he should automatic redirected to login page.
plz anybody can help.
plz plz
its urgent

推荐答案

让我们假设您拥有一个站点,该站点的母版页包含一些简单页面,并且用户拥有在登录过程中,请为会话分配一些内容,例如
Let''s assume you have a site with a master page that has a few simple pages and that the user has logged in. As part of the login process assign something to the Session, perhaps like
Session.Add(Key, Value);

.然后,例如,当用户每次导航到另一个页面或启动PostBack事件时,您都可以测试此值.

您可以这样做:

. You can then test for this value each time the user, for instance, navigates to another page or initiates a PostBack event.

You could do:

// Pseudo code.
if (Session[Key] == null)
{
    // Do something: user no longer valid.
}



如果Session过期,则Session变量将为null,您可以测试该变量并采取适当的措施.



If the Session has expired the Session variable will be null which you can test for and take the appropriate action.


将此代码写入web.config文件中的
write this code in web.config file under
<system.web>


<sessionstate timeout="15"></sessionstate>



默认情况下为20分钟.当用户在15分钟后会执行某项操作时.然后页面将重新加载并重定向到登录页面.

希望对您有帮助...
不要忘记标记它是否对您有帮助. :)



by default it is of 20 mins. when user will do something after 15 mins. then page will reload and redirect to login page.

hope it''ll help you...
Don''t forget to mark if it helps you. :)


这篇关于关于会话破坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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