468,249 Members | 1,496 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

How can we terminate a user's session

ad
In some condition, like another user log in with the some ID, I want to
close a user's session.
How can we terminate a user's session with program?
Nov 19 '05 #1
3 1792
"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:Or**************@TK2MSFTNGP10.phx.gbl...
In some condition, like another user log in with the some ID, I want to
close a user's session.
How can we terminate a user's session with program?


See my earlier reply about session timeout - basically, you can't...

Remember that IIS sessions are by definition independent of each other so,
unless you record each successful login in something like SQL Server, one
session can't have any knowledge about any other session.

However, if you do log each successful login, you could very simply add code
to the OnInit of each ASPX's code-behind which did something like:

if(<some condition fetched from SQL Server>)
{
Session.Abandon();
}
Nov 19 '05 #2
ad
Thanks for your immediately answer.
But I want close specific session, not the session right now.
My scenario:
I prepare a database table (name UserOnLine) to log the User ID and Session
ID of user.

When a use login with a ID (Say User1) I check the UserOnLine table, If
there no User1 in the UserOnLine table, run the common login process.
But if the User1 ID already in UserOnLine table:
1. Fetch the SessionID of User1 in UserOnLine table.
2. Abandon the Session of that SessionID
3. Process common login process.

My question is :
1. How to get the session ID when a user login?
2. How can we abandon a specific session?

"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> glsD:eN**************@TK2MSFTNGP09.phx.g bl...
"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:Or**************@TK2MSFTNGP10.phx.gbl...
In some condition, like another user log in with the some ID, I want to
close a user's session.
How can we terminate a user's session with program?


See my earlier reply about session timeout - basically, you can't...

Remember that IIS sessions are by definition independent of each other so,
unless you record each successful login in something like SQL Server, one
session can't have any knowledge about any other session.

However, if you do log each successful login, you could very simply add
code to the OnInit of each ASPX's code-behind which did something like:

if(<some condition fetched from SQL Server>)
{
Session.Abandon();
}

Nov 19 '05 #3
"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
1. How to get the session ID when a user login?
HttpContext.Current.Session.SessionI
2. How can we abandon a specific session?


Don't even try - rethink your application design...
Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.