session & browsers (final)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    #1

    session & browsers (final)

    I ask something relative later but the answer make me cry ;-)
    If we duplicate the browser window (both in IE / Mozilla), both of 2 browser windows use the same session!!!
    This produces many problems...

    My program is this:
    I have html format books inside zip files.
    If I choose a book from my main page, php sets
    $_SESSION['book'] = "a_book.zip ";
    and loads the index.html from a_book.zip.
    if we click a link inside index.html like:
    <a href=chapter1.h tml>Next</a>
    Apache returns error 404, php handles this error and returns file chapter1.html from a_book.zip

    All right but the problem is this:
    If I duplicate browser window and in the 2nd browser I select another book, then because both of 2 browser use the same session, 2nd
    browser change the $_SESSION['book'] and 1st browser searches in wrong zip file.

    Any suggestions?

    Regards
    Gessos Paul



  • Guest's Avatar

    #2
    Re: session &amp; browsers (final)


    "<- Chameleon ->" <cham_gss@hotma il.NOSPAM.com> a écrit dans le message de
    news: bnoqda$6ii$1@ni c.grnet.gr...[color=blue]
    > I ask something relative later but the answer make me cry ;-)
    > If we duplicate the browser window (both in IE / Mozilla), both of 2[/color]
    browser windows use the same session!!![color=blue]
    > This produces many problems...
    >
    > My program is this:
    > I have html format books inside zip files.
    > If I choose a book from my main page, php sets
    > $_SESSION['book'] = "a_book.zip ";
    > and loads the index.html from a_book.zip.
    > if we click a link inside index.html like:
    > <a href=chapter1.h tml>Next</a>
    > Apache returns error 404, php handles this error and returns file[/color]
    chapter1.html from a_book.zip[color=blue]
    >
    > All right but the problem is this:
    > If I duplicate browser window and in the 2nd browser I select another[/color]
    book, then because both of 2 browser use the same session, 2nd[color=blue]
    > browser change the $_SESSION['book'] and 1st browser searches in wrong zip[/color]
    file.[color=blue]
    >
    > Any suggestions?
    >
    > Regards
    > Gessos Paul[/color]

    sorry for makin' you cry :)

    for your problem, maybe you should try to use a random ID (or book name if
    unique) for each search made on your Zip or something like that.
    You should add something in your session to identify which book you're
    using.
    something like :
    $book["RANDOM_ID"]["BOOK"]
    $book["RANDOM_ID"]["OTHER_VAR_RELA TED_TO_THIS_BOO K"]

    You'll need to write a script to manage those vars and crush the session
    var.

    hope it'll help
    Regards,
    Julien.





    Comment

    • Guest's Avatar

      #3
      Re: session &amp; browsers (final)

      > > I have html format books inside zip files.[color=blue][color=green]
      > > If I choose a book from my main page, php sets
      > > $_SESSION['book'] = "a_book.zip ";
      > > and loads the index.html from a_book.zip.
      > > if we click a link inside index.html like:
      > > <a href=chapter1.h tml>Next</a>
      > > Apache returns error 404, php handles this error and returns file[/color]
      > chapter1.html from a_book.zip[color=green]
      > >
      > > All right but the problem is this:
      > > If I duplicate browser window and in the 2nd browser I select another[/color]
      > book, then because both of 2 browser use the same session, 2nd[color=green]
      > > browser change the $_SESSION['book'] and 1st browser searches in wrong zip file.[/color][/color]
      [color=blue]
      > for your problem, maybe you should try to use a random ID (or book name if
      > unique) for each search made on your Zip or something like that.
      > You should add something in your session to identify which book you're
      > using.
      > something like :
      > $book["RANDOM_ID"]["BOOK"]
      > $book["RANDOM_ID"]["OTHER_VAR_RELA TED_TO_THIS_BOO K"]
      >
      > You'll need to write a script to manage those vars and crush the session
      > var.[/color]

      Thank you for your response, but I don't understand. Sorry ;-(
      first of all book name is unique. I have 2 browser windows:
      1st has $_SESSION['book'] = 'php_manual.zip '
      2nd overide $_SESSION['book'] = 'thinking_in_cp lusplus.zip' because has the same session
      so when 1st gets image: image.jpg from an <A> tag, php search inside 'thinking_in_cp lusplus.zip' and not inside 'php_manual.zip '

      You suggest $_SESSION['book'] will be an array? How it help?
      thank you


      Comment

      • Jeffrey Silverman

        #4
        Re: session &amp; browsers (final)

        On Thu, 30 Oct 2003 17:38:18 +0200, <- Chameleon -> wrote:
        [color=blue]
        > Thank you for your response, but I don't understand. Sorry ;-(
        > first of all book name is unique. I have 2 browser windows:
        > 1st has $_SESSION['book'] = 'php_manual.zip '
        > 2nd overide $_SESSION['book'] = 'thinking_in_cp lusplus.zip' because has the same session
        > so when 1st gets image: image.jpg from an <A> tag, php search inside 'thinking_in_cp lusplus.zip' and not inside 'php_manual.zip '
        >
        > You suggest $_SESSION['book'] will be an array? How it help?
        > thank you[/color]

        He's saying that you need to use a unique identifier for each book OTHER
        than the generic name 'book'. (Also note that the session for a browser
        and ALL of its open windows is the same session.)

        So if book names are unique, track the book by using the name of the book,
        instead of the very generic variable name "$book".

        Something like

        $_SESSION['book_list']['a_book'] = 'a_book_file.zi p';
        $_SESSION['book_list']['b_book'] = 'b_book_file.zi p';
        $_SESSION['book_list']['c_book'] = 'c_book_file.zi p';

        etc...

        That makes an array $_SESSION['book_list']. Use that array to keep all
        the books in one place, but use a different key for each book, in this
        case the key is the book's name.

        Hope this helps. If not, then learn more about Arrays, Multi-dimensional
        arrays, Associative arrays, and Sessions. Go to
        http://www.php.net/manual/ for that.

        later...
        --
        Jeffrey D. Silverman | jeffrey AT jhu DOT edu
        Johns Hopkins University | Baltimore, MD
        Website | http://www.wse.jhu.edu/newtnotes/

        Comment

        • Guest's Avatar

          #5
          Re: session &amp; browsers (final)

          > He's saying that you need to use a unique identifier for each book OTHER[color=blue]
          > than the generic name 'book'. (Also note that the session for a browser
          > and ALL of its open windows is the same session.)
          >
          > So if book names are unique, track the book by using the name of the book,
          > instead of the very generic variable name "$book".
          >
          > Something like
          >
          > $_SESSION['book_list']['a_book'] = 'a_book_file.zi p';
          > $_SESSION['book_list']['b_book'] = 'b_book_file.zi p';
          > $_SESSION['book_list']['c_book'] = 'c_book_file.zi p';
          >
          > etc...
          >
          > That makes an array $_SESSION['book_list']. Use that array to keep all
          > the books in one place, but use a different key for each book, in this
          > case the key is the book's name.
          >
          > Hope this helps.[/color]

          Thank you but it is wrong ;-)
          Wrong because you want a key (the book's name).
          Where can I store this key? In Session? In this case we fall in the start of the problem.
          I cannot use GET, POST & COOKIE


          Comment

          • Jeffrey Silverman

            #6
            Re: session &amp; browsers (final)

            On Thu, 30 Oct 2003 21:44:33 +0200, <- Chameleon -> wrote:
            [color=blue]
            > Thank you but it is wrong ;-)
            > Wrong because you want a key (the book's name).
            > Where can I store this key? In Session? In this case we fall in the start of the problem.
            > I cannot use GET, POST & COOKIE[/color]

            You lost me there. Why can't you store the book's name in a session?
            --
            Jeffrey D. Silverman | jeffrey AT jhu DOT edu
            Johns Hopkins University | Baltimore, MD
            Website | http://www.wse.jhu.edu/newtnotes/

            Comment

            • Guest's Avatar

              #7
              Re: session &amp; browsers (final)

              > > Thank you but it is wrong ;-)[color=blue][color=green]
              > > Wrong because you want a key (the book's name).
              > > Where can I store this key? In Session? In this case we fall in the start of the problem.
              > > I cannot use GET, POST & COOKIE[/color]
              >
              > You lost me there. Why can't you store the book's name in a session?[/color]

              because 2nd browser windows which points in other book will overide 1st browser book's name.

              anyway, I found other method to accomplish:
              Until now I dont knew that:
              I can pass data with GET with this:
              book.php/thinking_in_cpl usplus.zip/index.html

              All are easy now

              thanks


              Comment

              Working...