Soluga
asked on
Log off a user when they leave web site
Hi,
I would like to log off a user if they leave my site.
I have tried a few things such as ....
window.onbeforeunload = function(){
$.ajax({
type: "POST",
//page and method
url: "../KeepSessionAlive.aspx/ logOutUser ",
async: false,
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
};
However this logs off the user if they leave the web page for another web page. I only want to invoke a log off if they actually navigate to another site altogether.
Would be grateful for any help.
Thanks
I would like to log off a user if they leave my site.
I have tried a few things such as ....
window.onbeforeunload = function(){
$.ajax({
type: "POST",
//page and method
url: "../KeepSessionAlive.aspx/
async: false,
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
};
However this logs off the user if they leave the web page for another web page. I only want to invoke a log off if they actually navigate to another site altogether.
Would be grateful for any help.
Thanks
Not going to happen. The browser does not know it is leaving the site until it has already left.
Why is it you think you ned to know when they leave the site?
Cd&
Why is it you think you ned to know when they leave the site?
Cd&
ASKER
Because if they leave the site and do not log off the web site then another user could potentially access the system by going back in history.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And even when it does work your alerts would not fire. There is only one option for the alert and that is 'Do you want to leave this website' - Yes/No (and the yes/no part you cannot change - or is it OK/Cancel - cannot remember)