Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to prevent two different login in a browser?  RSS feed

 
Neeraj Dhiman
Ranch Hand
Posts: 68
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
I am trying to prevent two different account login simultaneously in same browser.
How to prevent this? suggest me some technique to do this?

Thanks in advance
 
Prashant Chindhade
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use session.
for different browser tabs the session is same.
to show same user page on every tab if same url hit than. follow these steps.

1) create session when user first login.
2) store session info in tempDb
3) on every page check for session. if it is not null than redirect user to home page. else redirect to login page.
4)on every logout delete records from tempdb.

i have done this. in my application.
 
Tim Moores
Saloon Keeper
Posts: 3511
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to do this? (Please don't say: to prevent a user from being logged in multiple times - tells us *why* that's a bad thing.) You can (and maybe should) always put in an IP check to prevent multiple logins from different IPs.
 
ravi grk
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use single sign on funtionality this is used by Singleton desing pattern.
 
Tim Moores
Saloon Keeper
Posts: 3511
77
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Single sign on has nothing to do with this, or with the Singleton pattern.
 
Neeraj Dhiman
Ranch Hand
Posts: 68
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Tim, this is one problem:" to prevent a user from being logged in multiple times". but In my application if i login with account x and in another tab we login with account y.
then, there is a problem with data stored in session which causes a lot of trouble.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the two tabs or windows are sharing the same session how can anyone be logged in twice? How are you "logging people in"? Something sounds very screwy!
 
Neeraj Dhiman
Ranch Hand
Posts: 68
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Bear, Exactly this is my problem, trying to solve this.
when i logged in with account x in one tab. and in another tab logged in with y account.
Session get override and when i click on any thing on x account it open Y account.
So i am trying to prevent multiple login to resolve the issue.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be easy to check, when the login is occurring, if the session is already in use for another login.
 
Harshal Mekhale
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure,but Session will not get override as there will two different JSESSIONID associated with two different login.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!