• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to invalidate a session in one browser when the same user logs off from any other browser?  RSS feed

 
Pravin Kalekar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, I have created a web app , wherein , if a user logs in from two different browsers,
i want to invalidate the session in both the browsers , when he logs off from any one of the browsers.
Thank you
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36446
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pravin,
You can't do that specifically. You can log a user out of all sessions with a certain user id though. (Create a session listener and map the id to the session object.)
 
Pravin Kalekar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Pravin,
You can't do that specifically. You can log a user out of all sessions with a certain user id though. (Create a session listener and map the id to the session object.)


Hello Jeanne,

Is the user id you are talking about ,the unique login name i take from user?
Also,i map it to session for session handling..
I got upto this..
But what abt session listener?
I just use the session.invalidate() while logging out.
Please can you explain with some code?
Thanks for your quick reply..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pravin Kalekar wrote:But what abt session listener?

Please use real words when posting to the forums. Abbreviations such as "abt" in place of "about" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't make a browser "forget" a user was logged in.

(Well, technically that's not true: you could use an Ajax poller on the client that runs periodically and when the user is no longer logged in redirect to a login or splash page.)

But if a user logs out of the app from one browser it depends on the browser whether or not the session will be maintained: some browsers create new sessions for new windows, or new tabs. If you're talking about *across* browsers, there will be a new session created when the user logs in as the same user again. In that case you'd have to go by user ID, not session ID.
 
Pravin Kalekar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Bear,
Please excuse me once.It will not happen henceforth..

Thank you
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36446
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pravin Kalekar wrote:Is the user id you are talking about ,the unique login name i take from user?

Yes.

Pravin Kalekar wrote:But what abt session listener?
I just use the session.invalidate() while logging out.

If you want to listen for session timeouts, you would use the session listener. For explicit logouts, you wouldn't need to.

Pravin Kalekar wrote:Please can you explain with some code?

Understand the concepts is the first step. Once you have these, you can put together code and post it here for comment.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!