Hallo Monks!
I have a WEB application that works with Apache::ASP and Sessions, in which every time a user open a window the data in it is kept in a Session.
I need to support a way in which the same user can open more then one Session from the same machine.
Currently, when the user open two IE processes the application works great, since each process has its own Session.
Unfortunately, when the user open a new window using CTRL-N or use "open a new window", it seems as though the same Session is used.
Some will tell me, "Well, this is very important feature". Yes, I know. You don't want a user to "forget" his login, or anything, between windows. This is why this behavior is the default, and it is fine.
The question is - how can I work differently, meaning - every window, even opened by the same process, will have its own Session.

It seems at first that using $Session->Abandon() will do the trick. Unfortunately, it does not.
First of all, the abandon will actually take place only in the next query of the server. The code below will show you:
<HTML> <HEAD> </HEAD> <BODY> <pre> <% use strict; use Data::Dumper; print "<br>Session ID before Abandon:" . $Session->{S +essionID} . "<br>"; $Session->Abandon; print "Session ID after Abandon:" . $Session->{Sessio +nID} . "<br>"; %> </pre> </BODY> </HTML>
Instead of seeing two different Session IDs, before and after, I got the same Session ID. I believe that this is not for the reason it seems - that the Abandon is done before the execution, or something else. I believe this is because the Session object does not change in the server, and all the Abandon does is sending a new Session ID in the next request.

Second, it seems that even an abandoned session will be the same session for all of the windows opened by the same process. To see that I wrote an example, in which one button open a new window, and another button shows the document.cookie, and did the following scenario:
  1. Open two IE processes, both to the test.asp below.
  2. See that each of them has a different Session ID
  3. In both of them press "open new window".
  4. Now check the Session IDs in all four windows.
What I expected is that each window will have its own Session (I did Abandon for that). Instead, every process has its own Session ID, and the new opened windows "interfere" with the first opened windows...

The bottom line - if this is the only behavior a Session can have, why bother to call it a Session ID? This is actually a Process ID!
Therefore I am almost certain there IS a way to differ between sessions in the same process. Only question is - how.
TIA,
shushu

The Code:
<HTML> <script> function open_window (URL) { window.open(URL); } function show_session_id (URL) { alert(document.cookie); } </script> <HEAD> </HEAD> <BODY> <pre> <% use strict; use Data::Dumper; print "<br>Session ID before Abandon:" . $Session->{S +essionID} . "<br>"; $Session->Abandon; print "Session ID after Abandon:" . $Session->{Sessio +nID} . "<br>"; %> </pre> <BR> <BUTTON onclick=open_window('test.asp')>Open new window</butto +n> <BUTTON onclick=show_session_id()>Show Session ID</button> </BODY> </HTML>

In reply to New Session for new Window (or: Session ID vs. Process ID...) by shushu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.