Disappearing session variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pink Pig

    Disappearing session variables

    I'm trying to track down an annoying problem that only occurs when I
    access my pages on a remote server using IE6. If I run instead run
    from localhost, IE6 works fine, and if I use another browser on the
    remote site, there are no problems.

    I'm not really looking for help debugging. I'd just like to be pointed
    in the right direction.

    Essentially, what happens is this. When I start up (i.e. load
    index.php on my site), I am logged out. When I log in, I go to
    logincheck.php, which validates the login and transfers control back
    to index.php with a few session variables set to indicate that I am
    logged in. Up to here, everything works with all browsers and
    locations. Next, I execute a database search, which goes to
    searchresults.p hp to do the actual work, stuffs the results into
    session variables, and returns to index.php. When I do this on the
    remote site using IE6, the session variables set by the search are
    present, but the login variables have been lost, so that I appear to
    be once again logged out.

    I've tried with both register_global s = On and register_global s = Off
    with no change of behavior.

    Does anyone have a clue what could be happening to cause this? For the
    record, there are differences between localhost and the remote site.
    I'm running PHP 5.2.3 locally, but the remote version is 5.0.5. There
    may be other relevant differences as well.
  • Jerry Stuckle

    #2
    Re: Disappearing session variables

    Pink Pig wrote:
    I'm trying to track down an annoying problem that only occurs when I
    access my pages on a remote server using IE6. If I run instead run
    from localhost, IE6 works fine, and if I use another browser on the
    remote site, there are no problems.
    >
    I'm not really looking for help debugging. I'd just like to be pointed
    in the right direction.
    >
    Essentially, what happens is this. When I start up (i.e. load
    index.php on my site), I am logged out. When I log in, I go to
    logincheck.php, which validates the login and transfers control back
    to index.php with a few session variables set to indicate that I am
    logged in. Up to here, everything works with all browsers and
    locations. Next, I execute a database search, which goes to
    searchresults.p hp to do the actual work, stuffs the results into
    session variables, and returns to index.php. When I do this on the
    remote site using IE6, the session variables set by the search are
    present, but the login variables have been lost, so that I appear to
    be once again logged out.
    >
    I've tried with both register_global s = On and register_global s = Off
    with no change of behavior.
    >
    Does anyone have a clue what could be happening to cause this? For the
    record, there are differences between localhost and the remote site.
    I'm running PHP 5.2.3 locally, but the remote version is 5.0.5. There
    may be other relevant differences as well.
    >
    This is strange - the browser you're using doesn't have anything to do
    with the session data - only the session id is kept in a cookie. The
    data itself is on the server, and should be completely independent of
    anything else in the browser.

    The whole thing makes no sense at all.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Pink Pig

      #3
      Re: Disappearing session variables

      On Aug 3, 1:36 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
      The whole thing makes no sense at all.
      I know -- that's why I'm beating my head against the wall.

      The last time I had a baffling problem like this, it turned out to be
      an unmatched apostrophe in a string, but this time I've validated the
      HTML both before and after, and there are no errors to be found there.

      Comment

      • Jerry Stuckle

        #4
        Re: Disappearing session variables

        Pink Pig wrote:
        On Aug 3, 1:36 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
        >The whole thing makes no sense at all.
        >
        I know -- that's why I'm beating my head against the wall.
        >
        The last time I had a baffling problem like this, it turned out to be
        an unmatched apostrophe in a string, but this time I've validated the
        HTML both before and after, and there are no errors to be found there.
        That wouldn't be in the html - html has nothing to do with session data.

        I could understand if the session information was related to the server
        - for instance, you might be storing too much data in the session in the
        failing case. But again, this has nothing to do with the browser,
        unless you're storing browser-related information in the session.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Pink Pig

          #5
          Re: Disappearing session variables

          I'm now pursuing the theory that there's something going on in the
          get_browser() function under IE that's causing my problems.
          Incidentally, can anyone explain why, when I access a page with IE6,
          the value of $_ENV["HTTP_USER_AGEN T"] says that the browser is Mozilla/
          4.0?

          Comment

          • Andrew

            #6
            Re: Disappearing session variables

            IE6 returns:

            Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

            as it's HTTP_USER_AGENT . Google "HTTP_USER_AGEN T" to get some
            references/lists to possible values for the HTTP_USER_AGENT from popular web
            browsers.


            "Pink Pig" <bill@grandcent ralapartments.c omwrote in message
            news:7cf10b75-95e9-4780-9b93-078b9f31a9ec@79 g2000hsk.google groups.com...
            I'm now pursuing the theory that there's something going on in the
            get_browser() function under IE that's causing my problems.
            Incidentally, can anyone explain why, when I access a page with IE6,
            the value of $_ENV["HTTP_USER_AGEN T"] says that the browser is Mozilla/
            4.0?

            Comment

            • The Hajj

              #7
              Re: Disappearing session variables

              it sounds stupid, but double check that you have session_start()

              I did this to myself the other as I was building the front end first
              then the backend, made a new script and forgot session_start, DOH!

              Comment

              • Pink Pig

                #8
                Re: Disappearing session variables

                On Aug 4, 4:57 pm, The Hajj <hajji.hims...@ gmail.comwrote:
                it sounds stupid, but double check that you have session_start()
                >
                I did this to myself the other as I was building the front end first
                then the backend, made a new script and forgot session_start, DOH!
                Sorry, I'm battling with the stupid accessibility icon that somebody
                thought was a good idea. The last time I tried to reply, it failed at
                least 8 times. Maybe somebody should try to make sure that the code is
                actually readable.

                Comment

                • Pink Pig

                  #9
                  Re: Disappearing session variables

                  On Aug 4, 4:57 pm, The Hajj <hajji.hims...@ gmail.comwrote:
                  it sounds stupid, but double check that you have session_start()
                  >
                  I did this to myself the other as I was building the front end first
                  then the backend, made a new script and forgot session_start, DOH!
                  OK, I got a message through, so I'll try again.

                  I have a session_start at the beginning of every file. It's not
                  literally the first statement, since I put it into a common header
                  that gets included in every file, but it works correctly under Firefox
                  and Opera, so I don't think that that's the problem.

                  The closest thing that I've heard to a possible explanation is that if
                  you don't explicit write out the session variables at the end of a
                  page, then it is possible that the new page is being loaded before the
                  old page has properly closed. I added an explicit session_write_c lose
                  everywhere just in case, but that didn't help. FWIW, the behavior is
                  consistent -- it always fails in exactly the same way every time.

                  Comment

                  • Geoff Berrow

                    #10
                    Re: Disappearing session variables

                    Message-ID:
                    <a7bfe5c0-d816-487b-ac2b-e8fa0280169b@s5 0g2000hsb.googl egroups.comfrom
                    Pink Pig contained the following:
                    >The closest thing that I've heard to a possible explanation is that if
                    >you don't explicit write out the session variables at the end of a
                    >page, then it is possible that the new page is being loaded before the
                    >old page has properly closed. I added an explicit session_write_c lose
                    >everywhere just in case, but that didn't help. FWIW, the behavior is
                    >consistent -- it always fails in exactly the same way every time.
                    You mentioned the get_browser() function. Is your script designed to
                    react to different browsers in any way?
                    --
                    Geoff Berrow 011000100110110 0010000000110
                    001101101011011 001000110111101 100111001011
                    100110001101101 111001011100111 010101101011
                    The Slippery Hill Boys Tel: 07985 425932. American themed barn dances and bluegrass performances. Stoke on Trent, Newcastle under Lyme, Staffordshire, Cheshire and surrounding areas.

                    Comment

                    • Pink Pig

                      #11
                      Re: Disappearing session variables

                      On Aug 5, 3:09 am, Geoff Berrow <blthe...@ckdog .co.ukwrote:
                      You mentioned the get_browser() function.  Is your script designed to
                      react to different browsers in any way?
                      Very slightly. If the browser is IE, then I load a different style
                      sheet, but that's it. I was a bit leery of get_browser() anyway, so I
                      switched to HTTP_USER_AGENT instead, and loaded a different style
                      sheet for HTTP_USER_AGENT == "Mozilla/4.0 ..."

                      There are some differences, e.g. the content of the database is
                      different between the two hosts, but I can't see why it works with
                      Firefox and Opera but not IE. My daughter tested it with IE7, and
                      reports that it behaves the same as IE6 in this case.

                      I've googled this issue a lot, and it seems to be a common problem,
                      but the proposed solutions seem a bit ad hoc to me -- I always hate
                      making a problem go away without figuring out the cause, since it
                      usually comes back to bite me later.

                      I added a bit of debugging code to track the _SESSION keys at various
                      points. I should make a table of the expected versus actual results,
                      so let me give it a shot here:

                      Initially | After login | After search
                      Expected: <none | pdata;sid;prosp ectID |
                      pdata;sid;prosp ectID;srchlast; sqlvars
                      Actual: <none | pdata;sid;prosp ectID | srchlast;sqlvar s

                      Note that the lost keys were the ones set by the login -- the search
                      worked fine, and set the keys 'srchlast' and 'sqlvars'. The search
                      results were identical.

                      I forgot to check session_id() -- I'll add that and check again.

                      Comment

                      • Pink Pig

                        #12
                        Re: Disappearing session variables

                        On Aug 5, 1:06 pm, Pink Pig <b...@grandcent ralapartments.c omwrote:
                        I forgot to check session_id() -- I'll add that and check again.
                        Well, this narrows it down a bit. When I run with firefox, I get the
                        following results:

                        Initially: "session_id () =
                        153bf8b7c6d6377 db439e366bffd44 7b","session_ke ys = "
                        After login: "session_id () =
                        153bf8b7c6d6377 db439e366bffd44 7b","session_ke ys =
                        pdata;sid;prosp ectID"
                        After search: "session_id () =
                        153bf8b7c6d6377 db439e366bffd44 7b","session_ke ys =
                        pdata;sid;prosp ectID;srchlast; sqlvars"

                        This is what I expected. With IE6, however, I get:

                        Initially: "session_id () =
                        f00a1f91999a305 8892c6f8ad2ba69 d6","session_ke ys = "
                        After login: "session_id () =
                        373dfdd48d5276a 8fa31e2c0bebfcb 75","session_ke ys =
                        pdata;sid;prosp ectID"
                        After search: "session_id () =
                        f085ef49aba74f9 4e21107728e597e 9d","session_ke ys = srchlast;sqlvar s"

                        So why is IE causing PHP to create a new session_id() each time?

                        Comment

                        • Geoff Berrow

                          #13
                          Re: Disappearing session variables

                          Message-ID:
                          <bdbbaaa0-ee6d-41c9-8276-341fde5e27d9@j2 2g2000hsf.googl egroups.comfrom
                          Pink Pig contained the following:
                          >So why is IE causing PHP to create a new session_id() each time?
                          Something to do with the way you are accessing the database? IE seems
                          to be treating as if you were accessing a different server. I'm just
                          guessing here.

                          --
                          Geoff Berrow 011000100110110 0010000000110
                          001101101011011 001000110111101 100111001011
                          100110001101101 111001011100111 010101101011
                          The Slippery Hill Boys Tel: 07985 425932. American themed barn dances and bluegrass performances. Stoke on Trent, Newcastle under Lyme, Staffordshire, Cheshire and surrounding areas.

                          Comment

                          • The Hajj

                            #14
                            Re: Disappearing session variables

                            might have found a solution
                            Recently, I ran into a problem with an image gallery web application I am writing in PHP. Throughout development, which was done on my Windows laptop using XAMPP, everything worked perfec…


                            give her a try

                            Comment

                            • Michael Fesser

                              #15
                              Re: Disappearing session variables

                              ..oO(Pink Pig)
                              >On Aug 5, 3:09 am, Geoff Berrow <blthe...@ckdog .co.ukwrote:
                              >You mentioned the get_browser() function.  Is your script designed to
                              >react to different browsers in any way?
                              >
                              >Very slightly. If the browser is IE, then I load a different style
                              >sheet, but that's it. I was a bit leery of get_browser() anyway, so I
                              >switched to HTTP_USER_AGENT instead, and loaded a different style
                              >sheet for HTTP_USER_AGENT == "Mozilla/4.0 ..."
                              Such browser sniffing will _never_ work reliable. Drop that.
                              Instead use conditional comments to include IE-only stylesheets.

                              Micha

                              Comment

                              Working...