You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Peter Hubbard <pe...@staff.telkomsa.net> on 2006/05/11 12:34:39 UTC

Multiple browser windows sharing the same session - dirty hack solution

Quite simply, if you have already logged in to the system, you get
kicked out until later. Like so:

HttpSession session = request.getSession(true);
                
if (session.getAttribute("details")!=null)
{
     log.warn("Already logged in.");
     redirect="/errors/alreadyloggedin.jsp";
}
else
{
     session.setAttribute("details", client);                
     redirect = "/portal/portal.jsp";
} 


This gets me out of the problem of multiple logins through the same
browser window (Firefox and Opera) or the same PC (IE) having their
session information confused.

I've not found any other ways around this problem, or solutions of how
to allow individual browser windows and tabs to have individual session
data. Is there a real solution for this, and if so could some kind soul
please point me in the right direction?

Thanks

-- 
Peter Hubbard <pe...@staff.telkomsa.net>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Multiple browser windows sharing the same session - dirty hack solution

Posted by David Ron <da...@bandmerch.com>.
I think that you first have to define what you mean when you say, 
"logged in".  When a person closes the browser window, have they logged 
out?  How does Tomcat know this?  Or, does the logout occur when the 
session is garbage collected?

So, without knowing what "logged in" really means, how can you know if a 
person is actually logged in or not?

--David Ron

Peter Hubbard wrote:

>Quite simply, if you have already logged in to the system, you get
>kicked out until later. Like so:
>
>HttpSession session = request.getSession(true);
>                
>if (session.getAttribute("details")!=null)
>{
>     log.warn("Already logged in.");
>     redirect="/errors/alreadyloggedin.jsp";
>}
>else
>{
>     session.setAttribute("details", client);                
>     redirect = "/portal/portal.jsp";
>} 
>
>
>This gets me out of the problem of multiple logins through the same
>browser window (Firefox and Opera) or the same PC (IE) having their
>session information confused.
>
>I've not found any other ways around this problem, or solutions of how
>to allow individual browser windows and tabs to have individual session
>data. Is there a real solution for this, and if so could some kind soul
>please point me in the right direction?
>
>Thanks
>
>  
>

-- 
David Ron
IT Director - BandMerch
5126 Clareton Drive #140
Agoura Hills, CA 91301
877-502-3728 x5201
David@BandMerch.com



Re: Multiple browser windows sharing the same session - dirty hack solution

Posted by Paul Singleton <pa...@jbgb.com>.
Peter Hubbard wrote:
> ...
> I've not found any other ways around this problem, or solutions of how
> to allow individual browser windows and tabs to have individual session
> data.

One (the only?) sure way to allow multiple sessions to coexist in
a browser or PC is to spurn cookies and use only URL rewriting.

First you need to ensure that your servlet/JSP app uses

   response.encodeURL()

wherever it returns a URL referring to one of its own pages, e.g.

   <a href="<%= response.encodeURL("my.jsp") %>">me</a>

Then use the

   <Context cookies="false" ...>

attribute to stop session cookies being sent.

This has pros and cons but that's another topic...

Paul Singleton

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Multiple browser windows sharing the same session - dirty hack solution

Posted by David Rees <dr...@gmail.com>.
On 5/11/06, Michael Jouravlev <jm...@gmail.com> wrote:
> On 5/11/06, Peter Hubbard <pe...@staff.telkomsa.net> wrote:
> > how
> > to allow individual browser windows and tabs to have individual session
> > data. Is there a real solution for this, and if so could some kind soul
> > please point me in the right direction?
>
> You can't on Firefox, but "one window -> one session" is default setup for MSIE.

Unless you open that window by using Ctrl-N or File->New->Window, then
it shares the same sessions.

-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Multiple browser windows sharing the same session - dirty hack solution

Posted by Michael Jouravlev <jm...@gmail.com>.
On 5/11/06, Peter Hubbard <pe...@staff.telkomsa.net> wrote:
> how
> to allow individual browser windows and tabs to have individual session
> data. Is there a real solution for this, and if so could some kind soul
> please point me in the right direction?

You can't on Firefox, but "one window -> one session" is default setup for MSIE.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org