Connecting Tech Pros Worldwide Help | Site Map

YET ANOTHER QUESTION ON SESSION TIMEOUT AND SESSION_ONEND()

HolaGoogle
Guest
 
Posts: n/a
#1: Jul 20 '05
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...
Lasse Reichstein Nielsen
Guest
 
Posts: n/a
#2: Jul 20 '05

re: YET ANOTHER QUESTION ON SESSION TIMEOUT AND SESSION_ONEND()


holaasp@yahoo.com (HolaGoogle) writes:
[color=blue]
> 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???[/color]

No. They might not even be connected to the internet when they close
the browser.
[color=blue]
> 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???[/color]

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 - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
HolaGoogle
Guest
 
Posts: n/a
#3: Jul 20 '05

re: YET ANOTHER QUESTION ON SESSION TIMEOUT AND SESSION_ONEND()


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 <lrn@hotpop.com> wrote in message news:<ptfq4uk4.fsf@hotpop.com>...[color=blue]
> holaasp@yahoo.com (HolaGoogle) writes:
>[color=green]
> > 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???[/color]
>
> No. They might not even be connected to the internet when they close
> the browser.
>[color=green]
> > 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???[/color]
>
> 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[/color]
HolaGoogle
Guest
 
Posts: n/a
#4: Jul 20 '05

re: YET ANOTHER QUESTION ON SESSION TIMEOUT AND SESSION_ONEND()


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 <lrn@hotpop.com> wrote in message news:<ptfq4uk4.fsf@hotpop.com>...[color=blue]
> holaasp@yahoo.com (HolaGoogle) writes:
>[color=green]
> > 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???[/color]
>
> No. They might not even be connected to the internet when they close
> the browser.
>[color=green]
> > 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???[/color]
>
> 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[/color]
HolaGoogle
Guest
 
Posts: n/a
#5: Jul 20 '05

re: YET ANOTHER QUESTION ON SESSION TIMEOUT AND SESSION_ONEND()


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 <lrn@hotpop.com> wrote in message news:<ptfq4uk4.fsf@hotpop.com>...[color=blue]
> holaasp@yahoo.com (HolaGoogle) writes:
>[color=green]
> > 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???[/color]
>
> No. They might not even be connected to the internet when they close
> the browser.
>[color=green]
> > 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???[/color]
>
> 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[/color]
Closed Thread