2 sessions, 2 browser windows

  • Thread starter news-server.maine.rr.com
  • Start date
N

news-server.maine.rr.com

Hi,

I'm looking for sample code or your input, on how to create a new window
with a new session, while the parent window remains in its original session.

For example, a link from the parent window would open a new window in a new
session, but the parent session would still be valid.

Is this possible?

Thanks for any tips.

Frank
 
L

Laurent Bugnion [MVP]

Hi,

news-server.maine.rr.com said:
Hi,

I'm looking for sample code or your input, on how to create a new window
with a new session, while the parent window remains in its original session.

For example, a link from the parent window would open a new window in a new
session, but the parent session would still be valid.

Is this possible?

Thanks for any tips.

Frank

That's not possible. For the web browsers, the session is linked to the
process in which the web browser runs. If you start two instances of the
IE process (IEXPLORE.EXE), each one will have a distinct session ID.
However, if you just open a new window from the current instance of
IEXPLORE, the new window will run in the same process, thus have the
same Session ID. It is not possible using a link to start a new instance
of a process on the client, or to open a new window in another existing
instance of a process.

What you can do, however, is use another way to identify your windows
(for example using a combination of SessionID and window name, since the
window's name must be unique inside of a session), and to implement your
own "window-session" management on the server. it's not very difficult.

Also (you didn't precise what kind of client you have), if you have a
rich client (for example WinForms application), then you can start
multiple sessions from one client only using different CookieContainers
for each web request. I don't think it's what you're doing though.

Greetings,
Laurent
 
M

Mark Rae

However, if you just open a new window from the current instance of
IEXPLORE, the new window will run in the same process, thus have the same
Session ID.

This simply is not true - at least, not with IE7...

I just tried it... opened a debug page on my website which shows the
SessionID, then clicked Ctrl-N nine times - each of the 10 browser instances
has a different SessionID...
 
L

Laurent Bugnion [MVP]

Hi Mark,

Mark said:
This simply is not true - at least, not with IE7...

I just tried it... opened a debug page on my website which shows the
SessionID, then clicked Ctrl-N nine times - each of the 10 browser instances
has a different SessionID...

I suspect a server-side issue. What happens when you refresh one window,
is the SessionID the same, or is it different? Also, what happens with
Firefox?

I noticed that the session management changed quite a lot in ASP.NET 2.0
compared to 1.1. I just made a few quick tests here and I am having
troubles getting a consistent SessionID. I can't test more tonight
unfortunately.

Normally, IE7 behaves the same as IE6, and the SessionID is attached to
the process.

Greetings,
Laurent
 
L

Laurent Bugnion [MVP]

Hi Mark,

Mark said:
This simply is not true - at least, not with IE7...

I just tried it... opened a debug page on my website which shows the
SessionID, then clicked Ctrl-N nine times - each of the 10 browser instances
has a different SessionID...

OK, I got it. To have the SessionID set consistently on the server side,
you need to actually use the Session object. If you just observe the
SessionID, but you don't actually use the Session object for storage,
then the SessionID will be different on every request. I have to admit,
I was not aware of this. IIRC, it was different in 1.1 (but I might be
wrong).

Anyway, if you use the Session object for storage, and then observe the
session ID, it will be consistent when refreshing the page, and it will
also be the same if you open a new window using Ctrl-N.

HTH,
Laurent
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Laurent said:
Also, what happens with
Firefox?

In Firefix you can only have one instance of the browser application, so
you can't open separate sessions.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Laurent said:
OK, I got it. To have the SessionID set consistently on the server side,
you need to actually use the Session object. If you just observe the
SessionID, but you don't actually use the Session object for storage,
then the SessionID will be different on every request. I have to admit,
I was not aware of this. IIRC, it was different in 1.1 (but I might be
wrong).

I would rather suspect a change in IIS than a change in the framework.
 
M

Mark Rae

OK, I got it. To have the SessionID set consistently on the server side,
you need to actually use the Session object. If you just observe the
SessionID, but you don't actually use the Session object for storage, then
the SessionID will be different on every request. I have to admit, I was
not aware of this. IIRC, it was different in 1.1 (but I might be wrong).
Interesting...

Anyway, if you use the Session object for storage, and then observe the
session ID, it will be consistent when refreshing the page, and it will
also be the same if you open a new window using Ctrl-N.

So it would seem...!

I wonder just how absolutely consistent this is across client OS / browser
and version of IIS on the webserver...?
 
M

Mark Rae

In Firefix you can only have one instance of the browser application, so
you can't open separate sessions.

Utter nonsense!

Click the FireFox icon three times - three FireFox windows...
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Mark said:
Utter nonsense!

Not at all.

Just because you don't understand some information, it's not
automatically nonsense. ;)
Click the FireFox icon three times - three FireFox windows...

Yes, three windows, but one application instance.

Open the process list in the task manager and count it, if you like.
 
L

Laurent Bugnion [MVP]

Hi,

Göran Andersson said:
In Firefix you can only have one instance of the browser application, so
you can't open separate sessions.

I am aware of this, but that was not the question. The question was if
Firefox also gets a new SessionID when the current window gets
refreshed. Since then I found out that the reason for getting a new
Session ID on every request was not client-side (I first though of a
Cookie problem) but server-side. Apparently, the SessionID only gets set
consistently when the Session object is populated. I think it's a new
behaviour in 2.0 towards 1.1 but I am not sure, I will test.

Greetings,
Laurent
 
L

Laurent Bugnion [MVP]

Hi,

Göran Andersson said:
I would rather suspect a change in IIS than a change in the framework.

I am using the same IIS with ASP.NET 1.1 and ASP.NET 2.0. I should have
time later to test consistently between these two versions.

Greetings,
Laurent
 
L

Laurent Bugnion [MVP]

Hi Mark,

Mark said:
Interesting...

I found the entry in MSDN confirming this behaviour:

"When using cookie-based session state, ASP.NET does not allocate
storage for session data until the Session object is used. As a result,
a new session ID is generated for each page request until the session
object is accessed. If your application requires a static session ID for
the entire session, you can either implement the Session_Start method in
the application's Global.asax file and store data in the Session object
to fix the session ID, or you can use code in another part of your
application to explicitly store data in the Session object."

quoted from
http://msdn2.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.sessionid.aspx

So it would seem...!

I wonder just how absolutely consistent this is across client OS / browser
and version of IIS on the webserver...?

As far as we tested, this behaviour (Session ID linked to the process
instance) is consistent in all Windows versions that we support.
Actually, this is quite necessary if you think of it: When using pop-ups
in a web application, for example, or frames, it is not acceptable that
the Session object carries different values for each of these windows.
The values must be consistent.

Greetings,
Laurent
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Mark said:
Well obviously, but that's not what we're discussing in this thread

Is it not? Then perhaps you should read the entire thread, so that you
know what we are discussing.
- it's
whether the three windows share the same SessionID or not.

Is there anything that makes you think that whether the windows belong
to the same instance or not doesn't have anything to do with whether
they can have the same SessionID or not?
And, depending on
whether the Session is populated or not, they most clearly do not:
http://www.markrae.com/FireFoxSessions.jpg

As those windows doesn't belong to a session at all, it's irrelevant
what SessionID they had when the pages were created. They don't have
that SessionID any more.
Maybe you should read the entire thread...

I did.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Laurent said:
Hi,



I am aware of this, but that was not the question.

Yes, that *was* the question. ;)

You asked what happens with Firefox, and that's what happens with Firefox.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top