473,473 Members | 4,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cannot log out user when leaving and coming back to app

My customer wants a user to be logged out of the system when he uses the
same browser to navigate to a different
website (without explicitly logging out). In other words, if the user
navigates to a different website and uses the "Back" button to get back to
my application, he should have to log in again.

I know that I can detect on the client when the user navigates to another
website (Body OnUnload=) but I don't know how to go from here. Even when I
use the log out code in the procedure that gets called on unload (when the
user navigates to a different website), the user can just hit the "Back"
button the browser and be back in the application.

Can this be accomplished?

Thanks,

Sacha
Nov 19 '05 #1
6 2225
Do you mean browsing by clicking a link at your website or directly?

If it's by clicking a link: you can redirect using like
"redirect.aspx?url=<url>" and redirect.aspx can do the logout job.

Using, onunload, you'll need to a small popup that will do the logout.
Note that now browsers are very strict on popups.

Or I'm not sure if the following works:
onunload="logout()"

javascript function:

function logout()
{
document.cookies[".ASPXAUTH"] = null;
}

// Basically, you need to remove the .ASPXAUTH cookie or whatever name
you've set in web.config file.
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
----------------------

Nov 19 '05 #2
Yes, I meant navigating to a different site directly. I will try your
suggestion "document.cookies[".ASPXAUTH"] = null;" on Monday. That sounds
like it might work.

Thanks!

Sacha
"MasterGaurav" <ga**********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Do you mean browsing by clicking a link at your website or directly?

If it's by clicking a link: you can redirect using like
"redirect.aspx?url=<url>" and redirect.aspx can do the logout job.

Using, onunload, you'll need to a small popup that will do the logout.
Note that now browsers are very strict on popups.

Or I'm not sure if the following works:
onunload="logout()"

javascript function:

function logout()
{
document.cookies[".ASPXAUTH"] = null;
}

// Basically, you need to remove the .ASPXAUTH cookie or whatever name
you've set in web.config file.
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
----------------------

Nov 19 '05 #3
Yes, I meant navigating to a different site directly. I will try your
suggestion "document.cookies[".ASPXAUTH"] = null;" on Monday. That sounds
like it might work.

Thanks!

Sacha
"MasterGaurav" <ga**********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Do you mean browsing by clicking a link at your website or directly?

If it's by clicking a link: you can redirect using like
"redirect.aspx?url=<url>" and redirect.aspx can do the logout job.

Using, onunload, you'll need to a small popup that will do the logout.
Note that now browsers are very strict on popups.

Or I'm not sure if the following works:
onunload="logout()"

javascript function:

function logout()
{
document.cookies[".ASPXAUTH"] = null;
}

// Basically, you need to remove the .ASPXAUTH cookie or whatever name
you've set in web.config file.
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
----------------------


Nov 19 '05 #4
Just check the syntax in javascript. I'm not sure if it should be "=
null" or something else.

--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
----------------------

Nov 19 '05 #5
Thanks Gaurav, but the "document.cookie[".ASPXAUTH"] = null;" didn't seem to
work. I called the cookie before and after that line and got the same
content.
I am logging the user out after OnUnload fires by calling a postback event
and then "FormsAuthentication.SignOut()", but when the user returns back to
my web app, he can still navigate everywhere.

Now, I'm trying to see whether I can detect the difference between a browser
closing and navigating to a different URL. Do you know if that is possible?

Thanks,

Sacha
"MasterGaurav" <ga**********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Just check the syntax in javascript. I'm not sure if it should be "=
null" or something else.

--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
----------------------

Nov 19 '05 #6
I was suspecting.. that's why I recommended to read javascript as well.
;-)

Anyway.. you can do this:

document.cookie = ".ASPXAUTH=deleted; path=/ ; domain = yourdomain.com"

Basically, what matters is the value of the cookie. It should be
invalid, that's it.
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
----------------------

Nov 19 '05 #7

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

Similar topics

6
by: gsb | last post by:
I trying to use sessions to save a user name/id after login. If the user leaves the site and comes back, how do I force a new session and login?
8
by: Zvonko | last post by:
Hi! Is it possible to capture an event when user leaves the page and execute some code? Not when he closes the window. Any ideas?
6
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the...
24
by: Rob R. Ainscough | last post by:
VS 2005 I have: ClickOnce deployment User's that hate and or don't want to use an IE Client (don't blame them) I don't see how ASPX web pages are going to survive? With .NET 2.0 and clickonce...
2
by: dmateer | last post by:
I have the following code in an asp.net page: System.Data.OleDb.OleDbConnection cn = new System.Data.OleDb.OleDbConnection(); cn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data...
10
by: yaniv.dg | last post by:
hi all, i'm bumping into smething very starnge its very simple code but from some reason the program is acting strange this is my code: #include<stdio.h> #include<conio.h> void main(void) {...
8
by: pamelafluente | last post by:
I am reposting hoping better luck :) I can't achieve this simple thing: I have an animated gif in an image control (ImageProgress1). The image visibility is set to false. I want that when the...
18
by: sebastian | last post by:
Can this be done without client-side scripting? I thought sessions might be the answer but after some testing found that sometimes the old session data remained even after the user left the site...
4
by: daveh551 | last post by:
Okay, I feel like this is probably a stupid question, but... I have accessed sites that are pushing some scam that, when you go to leave the page it will pop up a box saying, "No, don't go, let...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.