473,624 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

logout the previous session for the same user

Hi,

If i login to the site again (may be in the same pc or
different pc), system must allow me in and end my previous
session.
How do i go about doing this?

This is to ensure that an user can have only one session
at a time.

thanks
Vincent
Nov 15 '05 #1
5 5656
I had to do something similar to this once. I'm not sure if this is the
"best" way to do it but here goes:

On user login I stored the users Session.Session ID and username into a
database. In the Session_End event of Global.asax I added code to delete
the username and session ID from the table. When the user logs in I check
the table to see if there is a current Session entry. If so I gave the user
a message that they had a currently open session and did not allow them to
login until the first session was either closed or timed out.

In your case I see you are looking to end the first session. I'm not sure
exactly how to do this but I would assume there is a way to do so if you
have the Session ID of the Session you would like to end. I'll do some
digging and will post back if I find an answer.

Bryan

"vincent" <an*******@disc ussions.microso ft.com> wrote in message
news:03******** *************** *****@phx.gbl.. .
Hi,

If i login to the site again (may be in the same pc or
different pc), system must allow me in and end my previous
session.
How do i go about doing this?

This is to ensure that an user can have only one session
at a time.

thanks
Vincent

Nov 15 '05 #2
yeah i store the username and sessionId in the database.
kindly get back to me if you have the answer.
thanks
-----Original Message-----
I had to do something similar to this once. I'm not sure if this is the"best" way to do it but here goes:

On user login I stored the users Session.Session ID and username into adatabase. In the Session_End event of Global.asax I added code to deletethe username and session ID from the table. When the user logs in I checkthe table to see if there is a current Session entry. If so I gave the usera message that they had a currently open session and did not allow them tologin until the first session was either closed or timed out.
In your case I see you are looking to end the first session. I'm not sureexactly how to do this but I would assume there is a way to do so if youhave the Session ID of the Session you would like to end. I'll do somedigging and will post back if I find an answer.

Bryan

"vincent" <an*******@disc ussions.microso ft.com> wrote in messagenews:03******* *************** ******@phx.gbl. ..
Hi,

If i login to the site again (may be in the same pc or
different pc), system must allow me in and end my previous session.
How do i go about doing this?

This is to ensure that an user can have only one session
at a time.

thanks
Vincent

.

Nov 15 '05 #3
Hello Vincent,

This is fairly easy. You can implement this either as a page filter or as a
method that you elect to call at the beginning of each page.
When you log in, you store the session id and user id in a database. Each
time you navigate from one page to another, you check the
database to see if the session id still matches the value in the db. If
not, you display the message "You've logged in to another computer...
this session has been disconnected." and you reroute the user to the login
page.

It really is that simple. Here's how it works.

Session1: Login -> data is stored in the database (Session 1 User Joe)
Session1: Jump to PageMain
Session1: PageMain checks database. Comparison works (Session 1 = 1, User
Joe = Joe)
Session2: Login -> data is stored in the database (Session 1 User Joe)
Session2: Jump to PageMain
Session2: PageMain checks database. Comparison works (Session 2 = 2, User
Joe = Joe)
Session1: User clicks link on PageMain to PageSomething
Session1: PageSomething checks database. Comparison fails (Session 1 = 2,
User Joe = Joe)
Session1: ends, user redirected to Login page

This works if the user is on the same PC but is logged in as another user,
or if the user is on a different PC. It may not work if the user logs in
twice on the same PC since the session number would be tracked by a cookie,
and the same cookie would be generated for each window. This is the nature
of a browser, and is by design.

If you are not implementing as a page filter, you have to remember to call
your "check the database" routine at the top of every page.

Hope this helps,
--- Nick

"vincent" <an*******@disc ussions.microso ft.com> wrote in message
news:03******** *************** *****@phx.gbl.. .
Hi,

If i login to the site again (may be in the same pc or
different pc), system must allow me in and end my previous
session.
How do i go about doing this?

This is to ensure that an user can have only one session
at a time.

thanks
Vincent

Nov 15 '05 #4
Hi Nick,

You are telling not allowing the user to login the second
time. But my situation is different. I allow the user the
second time but must logout his previous session.so when
he goes back to his previous session or first opened
browser, he should be kicked out (may be on any request to
the server).

Regards
vincent
-----Original Message-----
Hello Vincent,

This is fairly easy. You can implement this either as a page filter or as amethod that you elect to call at the beginning of each page.When you log in, you store the session id and user id in a database. Eachtime you navigate from one page to another, you check the
database to see if the session id still matches the value in the db. Ifnot, you display the message "You've logged in to another computer...this session has been disconnected." and you reroute the user to the loginpage.

It really is that simple. Here's how it works.

Session1: Login -> data is stored in the database (Session 1 User Joe)Session1: Jump to PageMain
Session1: PageMain checks database. Comparison works (Session 1 = 1, UserJoe = Joe)
Session2: Login -> data is stored in the database (Session 1 User Joe)Session2: Jump to PageMain
Session2: PageMain checks database. Comparison works (Session 2 = 2, UserJoe = Joe)
Session1: User clicks link on PageMain to PageSomething
Session1: PageSomething checks database. Comparison fails (Session 1 = 2,User Joe = Joe)
Session1: ends, user redirected to Login page

This works if the user is on the same PC but is logged in as another user,or if the user is on a different PC. It may not work if the user logs intwice on the same PC since the session number would be tracked by a cookie,and the same cookie would be generated for each window. This is the natureof a browser, and is by design.

If you are not implementing as a page filter, you have to remember to callyour "check the database" routine at the top of every page.
Hope this helps,
--- Nick

"vincent" <an*******@disc ussions.microso ft.com> wrote in messagenews:03******* *************** ******@phx.gbl. ..
Hi,

If i login to the site again (may be in the same pc or
different pc), system must allow me in and end my previous session.
How do i go about doing this?

This is to ensure that an user can have only one session
at a time.

thanks
Vincent

.

Nov 15 '05 #5
i could finally get around doing this.Thanks
-----Original Message-----
Hi,

If i login to the site again (may be in the same pc or
different pc), system must allow me in and end my previoussession.
How do i go about doing this?

This is to ensure that an user can have only one session
at a time.

thanks
Vincent
.

Nov 15 '05 #6

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

Similar topics

7
5178
by: Angelos | last post by:
Any Suggestions for an Authentication System ... Do you have any Links to suggest ? My current Authentication works ok but it has a major BUG !!! BUG: If I use the same Authentication mechanism in Two Different Websites and I login in one of the two... Then I can change the URL to the other website and it will log me in as the user of the other Website. Anyway... I knew when I was writing that is not going to be perfect... but
4
7803
by: Chris Stegeman | last post by:
Hello there, On my site people have to log in and automatically start a session. An authorized login grants access to other pages and MySQL data. However when the user waits to long, the server ends the session, without a proper logout. The user can't see that he is logged out, hits a button and gets mutiple errors because MySQL is no longer available. Is there a way to to warn the user a minute before the session is ended? I just...
2
8991
by: Fabrice | last post by:
Hello, I 'would like to build a system (based on database, not SqlServer but MySQL) to permit only one session per user. I'm using a form athentication. My Solution : --------------- When a connection is established by a user, I realize an insert in a Table, named tbLogin with many informations such as idUser, SessionId, Guid, Date,
0
3887
by: swiss | last post by:
how can i code logout in a struts application.I have used session.invalidate but it is not accurately logging out from the session .please help me out to solve this problem.
3
1448
by: pardhu | last post by:
I have been trying out the sessions in PHP. Am able to log into a my site and sessions for that particular logged on session. My problem is with the logout. Am unsetting and destorying the session on my way out but when I click on the back button on my browser, I am able to view my last visited page. how can i get around this?
4
2017
by: agarwalsunitadhn | last post by:
my problem is that after every 20minutes i got the error that the Object reference not set to an instance of an object. and highlight the line lblWelcome.Text = "Welcome, " + Session.ToString(); I want that when the session expires either user will see LogIn page or the sesion resume their values. Where i write the code for the above.... thanks for your code in advance
2
2639
by: =?Utf-8?B?bXVzY2xla2luZw==?= | last post by:
say i have a form with many input text boxes, what is the proper way to store these values so when the next time the user opens the form, all the input from last session remains in the form? people recommend me to have a "cookie" file or registry to read and write from every time. but is there an easier way to do this, such as a feature in the .NET forms that i haven't found out yet. thank you
4
2035
by: Jats4U | last post by:
Hello, I want my web application user to login as many times as he wants but on every successive login, the application should automatically take care of logging out the previuos session for that user. My web application will be used by multiple users at a single point of time..so the solution should take care of the performance issue as well.. Please let me know if you any clue as on how to achieve this. Thanks,
0
8234
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8172
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8620
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2605
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 we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.