473,320 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

YET ANOTHER QUESTION ON SESSION TIMEOUT AND SESSION_ONEND()

hi there,
i've 2 questions for you guys....
1: is there any way to "force" a session_onend(), session timeout or
at least call my logout method when a user leaves the application
window without logging out? i.e: using the "X" in the right corner???
i'd like to reset to their default all my variables session?? is this
possible???

2: I've succesfully been able to ask the user to confirm whether he
wants to extend his session before it ends due to inactivity. This
works perfectly and my question is: if the user is not there to answer
the question is there any way to automaticaly end the session after 1
minutes without any answer???

i.e:
function UserToConfirm()
{
if (confirm('Hey...your session is about to time out extend?'))//if
the user
//is not there to answer, then force log out ho to do this?????
{
clearTimeout(SessionTimer );
}
else
{
parent.top.location.href = 'LogOut.asp';

}
}

function SetSessionTimer()
{
if(SessionTimer > 0)
{
clearTimeout(SessionTimer );
}
TimeOutID = setTimeout("UserToConfirm()",120000);//2
minutes
//before session ends
}
and i call my SetSessionTimer() method in my body onload event...
thanks a lot...
Jul 20 '05 #1
4 4813
ho*****@yahoo.com (HolaGoogle) writes:
hi there,
i've 2 questions for you guys....
1: is there any way to "force" a session_onend(), session timeout or
at least call my logout method when a user leaves the application
window without logging out? i.e: using the "X" in the right corner???
No. They might not even be connected to the internet when they close
the browser.
2: I've succesfully been able to ask the user to confirm whether he
wants to extend his session before it ends due to inactivity. This
works perfectly and my question is: if the user is not there to answer
the question is there any way to automaticaly end the session after 1
minutes without any answer???


Probably. Don't use a modal confirm dialog, though. You have no way
of making that go away after one minute. If you use HTML to pose
the question, you can remove it again, and then do whatever you want.

I.e., something like:
---
/**
* text : text to display for yes/no answer
* onYes : optional, function called if yes chosen
* onNo : optional, function called if no chosen
* timeout : optional, time in milliseconds before defaulting
* timeoutDefault: optional, default answer for timeout
*
* Don't omit both onYes and onNo.
*/
function myConfirm(text,onYes,onNo,timeout,timeoutDefault) {
var div = document.createElement("div");
div.style.border = "3px grey outset";
div.style.width="8em";
div.style.height="6em";
div.style.background = "grey";
div.style.position = "absolute"; // or use fixed
div.style.left = "10em";
div.style.top = "10em"; // do something to make sure it is visible
var p = document.createElement("p");
p.appendChild(document.createTextNode(text));
div.appendChild(p);
var div2 = document.createElement("div");
div2.style.textAlign = "center";
var butYes = document.createElement("input");
butYes.style.margin="0px 5px";
butYes.type="button";
butYes.value="Yes";
butYes.onclick= function(){action(true);};
var butNo = document.createElement("input");
butNo.style.margin="0px 5px";
butNo.type="button";
butNo.value="No";
butNo.onclick= function(){action(false);};
div2.appendChild(butYes);
div2.appendChild(butNo);
div.appendChild(div2);
div.style.zIndex = 1;
document.body.appendChild(div);
if (timeout) {
var timer = setTimeout(function(){action(timeoutDefault);},tim eout);
}
function action(choice) {
clearTimeout(timer);
document.body.removeChild(div);
if (choice) { if (onYes) {onYes();}}
else { if (onNo) {onNo();} }
}
}
---
You can call it as, e.g.,:
---
myConfirm("Are you sure?",
function(){alert("yes");},function(){alert("no");} ,
5000,true);
---
You should do something more to make sure the dialogue is visible, even
if the page is scrolled down.

You can save code space by having the confirm HTML already in the page,
and just changing the actions and text.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Thanks Lasse for your quick answer...i<ll try your solution and let
you know...yeah you<Re right i tried everything to make my confirm
dialog go away after 1 minute and couldn't. So i'm gonna try you way
and see what happens.

For my 1st question, i do have a logout method, is there any way that
i could use this instead of calling session_end() to force the user to
logout when he exits the application???

Thanks a lot once again....

Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<pt**********@hotpop.com>...
ho*****@yahoo.com (HolaGoogle) writes:
hi there,
i've 2 questions for you guys....
1: is there any way to "force" a session_onend(), session timeout or
at least call my logout method when a user leaves the application
window without logging out? i.e: using the "X" in the right corner???


No. They might not even be connected to the internet when they close
the browser.
2: I've succesfully been able to ask the user to confirm whether he
wants to extend his session before it ends due to inactivity. This
works perfectly and my question is: if the user is not there to answer
the question is there any way to automaticaly end the session after 1
minutes without any answer???


Probably. Don't use a modal confirm dialog, though. You have no way
of making that go away after one minute. If you use HTML to pose
the question, you can remove it again, and then do whatever you want.

I.e., something like:
---
/**
* text : text to display for yes/no answer
* onYes : optional, function called if yes chosen
* onNo : optional, function called if no chosen
* timeout : optional, time in milliseconds before defaulting
* timeoutDefault: optional, default answer for timeout
*
* Don't omit both onYes and onNo.
*/
function myConfirm(text,onYes,onNo,timeout,timeoutDefault) {
var div = document.createElement("div");
div.style.border = "3px grey outset";
div.style.width="8em";
div.style.height="6em";
div.style.background = "grey";
div.style.position = "absolute"; // or use fixed
div.style.left = "10em";
div.style.top = "10em"; // do something to make sure it is visible
var p = document.createElement("p");
p.appendChild(document.createTextNode(text));
div.appendChild(p);
var div2 = document.createElement("div");
div2.style.textAlign = "center";
var butYes = document.createElement("input");
butYes.style.margin="0px 5px";
butYes.type="button";
butYes.value="Yes";
butYes.onclick= function(){action(true);};
var butNo = document.createElement("input");
butNo.style.margin="0px 5px";
butNo.type="button";
butNo.value="No";
butNo.onclick= function(){action(false);};
div2.appendChild(butYes);
div2.appendChild(butNo);
div.appendChild(div2);
div.style.zIndex = 1;
document.body.appendChild(div);
if (timeout) {
var timer = setTimeout(function(){action(timeoutDefault);},tim eout);
}
function action(choice) {
clearTimeout(timer);
document.body.removeChild(div);
if (choice) { if (onYes) {onYes();}}
else { if (onNo) {onNo();} }
}
}
---
You can call it as, e.g.,:
---
myConfirm("Are you sure?",
function(){alert("yes");},function(){alert("no");} ,
5000,true);
---
You should do something more to make sure the dialogue is visible, even
if the page is scrolled down.

You can save code space by having the confirm HTML already in the page,
and just changing the actions and text.

/L

Jul 20 '05 #3
Thanks Lasse for your quick answer...i<ll try your solution and let
you know...yeah you<Re right i tried everything to make my confirm
dialog go away after 1 minute and couldn't. So i'm gonna try you way
and see what happens.

For my 1st question, i do have a logout method, is there any way that
i could use this instead of calling session_end() to force the user to
logout when he exits the application???

Thanks a lot once again....

Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<pt**********@hotpop.com>...
ho*****@yahoo.com (HolaGoogle) writes:
hi there,
i've 2 questions for you guys....
1: is there any way to "force" a session_onend(), session timeout or
at least call my logout method when a user leaves the application
window without logging out? i.e: using the "X" in the right corner???


No. They might not even be connected to the internet when they close
the browser.
2: I've succesfully been able to ask the user to confirm whether he
wants to extend his session before it ends due to inactivity. This
works perfectly and my question is: if the user is not there to answer
the question is there any way to automaticaly end the session after 1
minutes without any answer???


Probably. Don't use a modal confirm dialog, though. You have no way
of making that go away after one minute. If you use HTML to pose
the question, you can remove it again, and then do whatever you want.

I.e., something like:
---
/**
* text : text to display for yes/no answer
* onYes : optional, function called if yes chosen
* onNo : optional, function called if no chosen
* timeout : optional, time in milliseconds before defaulting
* timeoutDefault: optional, default answer for timeout
*
* Don't omit both onYes and onNo.
*/
function myConfirm(text,onYes,onNo,timeout,timeoutDefault) {
var div = document.createElement("div");
div.style.border = "3px grey outset";
div.style.width="8em";
div.style.height="6em";
div.style.background = "grey";
div.style.position = "absolute"; // or use fixed
div.style.left = "10em";
div.style.top = "10em"; // do something to make sure it is visible
var p = document.createElement("p");
p.appendChild(document.createTextNode(text));
div.appendChild(p);
var div2 = document.createElement("div");
div2.style.textAlign = "center";
var butYes = document.createElement("input");
butYes.style.margin="0px 5px";
butYes.type="button";
butYes.value="Yes";
butYes.onclick= function(){action(true);};
var butNo = document.createElement("input");
butNo.style.margin="0px 5px";
butNo.type="button";
butNo.value="No";
butNo.onclick= function(){action(false);};
div2.appendChild(butYes);
div2.appendChild(butNo);
div.appendChild(div2);
div.style.zIndex = 1;
document.body.appendChild(div);
if (timeout) {
var timer = setTimeout(function(){action(timeoutDefault);},tim eout);
}
function action(choice) {
clearTimeout(timer);
document.body.removeChild(div);
if (choice) { if (onYes) {onYes();}}
else { if (onNo) {onNo();} }
}
}
---
You can call it as, e.g.,:
---
myConfirm("Are you sure?",
function(){alert("yes");},function(){alert("no");} ,
5000,true);
---
You should do something more to make sure the dialogue is visible, even
if the page is scrolled down.

You can save code space by having the confirm HTML already in the page,
and just changing the actions and text.

/L

Jul 20 '05 #4
Hi Lasse,

étried your suggestion but it doesn't work for me. my browser doesn't
do anything...well it's ok...i try to fin some other solution....
thanks a lot though!

Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<pt**********@hotpop.com>...
ho*****@yahoo.com (HolaGoogle) writes:
hi there,
i've 2 questions for you guys....
1: is there any way to "force" a session_onend(), session timeout or
at least call my logout method when a user leaves the application
window without logging out? i.e: using the "X" in the right corner???


No. They might not even be connected to the internet when they close
the browser.
2: I've succesfully been able to ask the user to confirm whether he
wants to extend his session before it ends due to inactivity. This
works perfectly and my question is: if the user is not there to answer
the question is there any way to automaticaly end the session after 1
minutes without any answer???


Probably. Don't use a modal confirm dialog, though. You have no way
of making that go away after one minute. If you use HTML to pose
the question, you can remove it again, and then do whatever you want.

I.e., something like:
---
/**
* text : text to display for yes/no answer
* onYes : optional, function called if yes chosen
* onNo : optional, function called if no chosen
* timeout : optional, time in milliseconds before defaulting
* timeoutDefault: optional, default answer for timeout
*
* Don't omit both onYes and onNo.
*/
function myConfirm(text,onYes,onNo,timeout,timeoutDefault) {
var div = document.createElement("div");
div.style.border = "3px grey outset";
div.style.width="8em";
div.style.height="6em";
div.style.background = "grey";
div.style.position = "absolute"; // or use fixed
div.style.left = "10em";
div.style.top = "10em"; // do something to make sure it is visible
var p = document.createElement("p");
p.appendChild(document.createTextNode(text));
div.appendChild(p);
var div2 = document.createElement("div");
div2.style.textAlign = "center";
var butYes = document.createElement("input");
butYes.style.margin="0px 5px";
butYes.type="button";
butYes.value="Yes";
butYes.onclick= function(){action(true);};
var butNo = document.createElement("input");
butNo.style.margin="0px 5px";
butNo.type="button";
butNo.value="No";
butNo.onclick= function(){action(false);};
div2.appendChild(butYes);
div2.appendChild(butNo);
div.appendChild(div2);
div.style.zIndex = 1;
document.body.appendChild(div);
if (timeout) {
var timer = setTimeout(function(){action(timeoutDefault);},tim eout);
}
function action(choice) {
clearTimeout(timer);
document.body.removeChild(div);
if (choice) { if (onYes) {onYes();}}
else { if (onNo) {onNo();} }
}
}
---
You can call it as, e.g.,:
---
myConfirm("Are you sure?",
function(){alert("yes");},function(){alert("no");} ,
5000,true);
---
You should do something more to make sure the dialogue is visible, even
if the page is scrolled down.

You can save code space by having the confirm HTML already in the page,
and just changing the actions and text.

/L

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: MostlyH2O | last post by:
Hi Folks, I'm having a hard time getting my Session_OnEnd event to fire in my global.asa. Here's what I have: <SCRIPT LANGUAGE=VBSCRIPT RUNAT=Server> SUB Session_OnStart Session.TimeOut =...
8
by: Rune | last post by:
Hi, I'm developing web surveys where users logon to a web survey and answer up to about 50 questions, one after the other, shown only one question at a time. The answers are saved in a database....
12
by: Jim | last post by:
The dreaded Session state :-) All, Just to give a little background this is reagarding an ASP 3.0 application running on IIS6 using the default app pool. I have set the session timeout to 540...
4
by: Murray Foxcroft | last post by:
Hi all, My client, bless his soul, wants to know how long users of his ASP.NET web application (written by yours truly) spend logged in to the system. Now, I can log when he logs in, no problem,...
6
by: Weave | last post by:
I would like to redirect to a logout page after a session has timed out. I have placed a response.redirect "loggedoff.asp" in the Session_OnEnd subroutine in the global.asa, but it does not move...
11
by: Vishal | last post by:
Hello, can anybody tell me how I can extend the session expiry time? Is it done via code or via IIS? Sorry I am new and dont know about this.
17
by: jensen bredal | last post by:
Hello, i'm struggling with a somehow badly understood session scenario. I provide acces to my pages based on form authentication using Session cookies. Som of my pages are supposed to be...
4
by: abcd | last post by:
When IIS is restarted session_onEnd is called. though the debugger is not available at this point in Session_onEnd, is there any way that the code in session_onEnd is running due to iis restart and...
2
by: buu | last post by:
how could I handle session timeout event in asp.net? I would like to perform some action on database when it happens
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.