You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Adam Lipscombe <ad...@expensys.com> on 2008/02/21 18:32:13 UTC

Sharing session across IE windows

Folks,


I have a perplexing problem. I don't think its a tomcat issue but maybe someone else has encountered it?


In my app I spawn a new IE window with window.open(). I want the new window to share the same 
session as the parent, because it needs to access some session data.

I find that sometimes the new window shares the session, but sometimes a new session is created. In 
the latter case the session data is not available and the app fails. When a new session is created, 
repeated windows.open() calls that spawn the same child window all seem to re-use this new session.

I cannot determine what makes the new window session share the session sometimes but not others. It 
seems completely random.


I have a tried couple of things:

1. Giving the window a unique name in the window.open() call like this:
    window.open(url, "W+<%=session.getId()", options);

2. Passing the session ID to window.open) as part of the url like this:
    var myUrl = url + ";JSESSIONID=<%=session.getId()"
    window.open(myUrl ,....)


Neither of these make it work reliably.
My research shows that its probably an IE issue, and the general rule of thumb is not to try to 
share sessions across multiple windows 
(http://classicasp.aspfaq.com/general/how-do-i-manage-a-session-across-multiple-windows.html)


Does anyone have any ideas about this?


TIA - Adam








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


Re: Sharing session across IE windows

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Adam,

Adam Lipscombe wrote:
| In my app I spawn a new IE window with window.open(). I want the new
| window to share the same session as the parent, because it needs to
| access some session data.

If you are using cookies to track session ids, this should happen with
no work on your part. If you need to support cookie-less users, you will
need to...

| 1. Giving the window a unique name in the window.open() call like this:
|    window.open(url, "W+<%=session.getId()", options);

The name of the window should be irrelevant.

| 2. Passing the session ID to window.open) as part of the url like this:
|    var myUrl = url + ";JSESSIONID=<%=session.getId()"
|    window.open(myUrl ,....)

This is a slightly better strategy, but what you really want to do is:

var myUrl = "<%= response.encodeURL(url) %>"; window.open(myUrl);

When you use response.encodeURL, the server will decide if the
jsessionid parameter (which is lowercase, by the way) is necessary and
add it if so.

| Neither of these make it work reliably.
| My research shows that its probably an IE issue, and the general rule of
| thumb is not to try to share sessions across multiple windows
|
(http://classicasp.aspfaq.com/general/how-do-i-manage-a-session-across-multiple-windows.html)


It's funny, because most people posting to this list are asking how to
do just that: open a new window with a separate session. The only good
way to do that is the opposite of what you need to do: turn off cookies
and then /intentionally/ suppress the jsessionid parameter from being
added to the URL that will go into the popup.

Funny how the world works that way.

Hope that helps,
- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAke98w8ACgkQ9CaO5/Lv0PDf2gCeM8dofrklolX5rk7bnRpppuq1
3NUAnAvXkPkxcZv7Vg5fzBbE9pOFOGWQ
=6Oiu
-----END PGP SIGNATURE-----

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