admin管理员组文章数量:1277903
I have a requirement for session timeout. This is my requirement. Once logged in to my application, a time count sholud start. If it reaches 10 mins, it should gives a alert which prompting as
do you want to continue?
If customer press "Yes" the session should continue and time resetted as 0. If press "No", the session should close and error page need to e. I need this changes in javascript and jsp. Can any one have idea about this?
I have a requirement for session timeout. This is my requirement. Once logged in to my application, a time count sholud start. If it reaches 10 mins, it should gives a alert which prompting as
do you want to continue?
If customer press "Yes" the session should continue and time resetted as 0. If press "No", the session should close and error page need to e. I need this changes in javascript and jsp. Can any one have idea about this?
Share Improve this question edited Nov 24, 2011 at 12:47 robert 8,7179 gold badges46 silver badges70 bronze badges asked Nov 24, 2011 at 12:34 NagarajanNagarajan 4323 gold badges12 silver badges28 bronze badges 2-
Use
setTimeout()
function in JS – Aleks G Commented Nov 24, 2011 at 12:38 - Alerk am using frameset. On Page load i gave the frame set. On each time loading the frame it is resetting. – Nagarajan Commented Nov 24, 2011 at 12:41
2 Answers
Reset to default 6In your frameset file, you can have this:
<script type="text/javascript">
window.setTimeout('checkIfContinue()', 10*60*1000); //10 minutes
function checkIfContinue()
{
if(confirm("Do you want to continue?"))
{
window.setTimeout('checkIfContinue()', 10*60*1000); //start the timer again
}
else
{
window.location = 'timeout.html';
}
}
</script>
Of course, if you need a fancy dialog box, then you'll need to code that instead of using javascript function confirm
.
I'm not sure if you're looking for a plete code example. But briefly, I would say that you should use ajax on the client side to ping the server once a minute or so, to see if the timeout has expired. But then, if it has, there's a challenge. The server tells the client, "the session has expired," but then what? If the user doesn't respond with "yes," you want the session to timeout? If so, then how long does the server wait to hear back from the client before timing out? What if the user doesn't click "yes" for 30 seconds? So it can get sticky, and you would have to decide on the rules.
If no action is taken unless the user clicks "no" then this isn't a problem.
However I should also say that I don't think it's a good idea to ask visitors if they want to continue. It makes visitors feel like they are being pestered to leave.
本文标签: javascriptSession Timeout creation for applicationStack Overflow
版权声明:本文标题:javascript - Session Timeout creation for application - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741267233a2368705.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论