Deleting session with connection open

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Derek Fountain

    #1

    Deleting session with connection open

    I've got a function that builds a webpage containing a flash animation.
    As the page goes to the browser, the browser sees the link to the
    embedded FLV file and opens a new connection to retrieve it. A moment
    later the page download is completed, and a few seconds after that,
    depending on the user's connection speed, the FLV download completes and
    the use has the content. All fine.

    The issue comes if the user receives the page, but then hits the
    'logout' link on it before the FLV has completely downloaded. The
    browser goes to fetch the logout page (which deletes the session, etc.)
    but it seems that since there's still a connection open for the FLV
    stream something odd happens. It appears the session doesn't get
    deleted. If, having received the logout page, the user hits their back
    button, they go back to the previous page and it all still works - they
    haven't been logged out.

    This doesn't happen every time, so I'm guessing it's a race condition.
    Can anyone explain what's happening and what I can do about it?

    --
    Derek Fountain on the web at http://www.derekfountain.org/
  • Rik Wasmus

    #2
    Re: Deleting session with connection open

    On Tue, 01 Jan 2008 12:05:34 +0100, Derek Fountain
    <nomail@hursley .ibm.comwrote:
    I've got a function that builds a webpage containing a flash animation.
    As the page goes to the browser, the browser sees the link to the
    embedded FLV file and opens a new connection to retrieve it. A moment
    later the page download is completed, and a few seconds after that,
    depending on the user's connection speed, the FLV download completes and
    the use has the content. All fine.
    >
    The issue comes if the user receives the page, but then hits the
    'logout' link on it before the FLV has completely downloaded. The
    browser goes to fetch the logout page (which deletes the session, etc.)
    but it seems that since there's still a connection open for the FLV
    stream something odd happens. It appears the session doesn't get
    deleted. If, having received the logout page, the user hits their back
    button, they go back to the previous page and it all still works - they
    haven't been logged out.
    >
    This doesn't happen every time, so I'm guessing it's a race condition.
    Can anyone explain what's happening and what I can do about it?

    1. If the FLV file is served/created/altered with PHP, get all session
    variables you need straight at the beginning, and call
    session_write_c lose() immediatelly after it before doing any other work.
    2. If it's not served with PHP, there is another problem, an we'd like to
    see your logout code.
    --
    Rik Wasmus

    Comment

    • Derek Fountain

      #3
      Re: Deleting session with connection open

      1. If the FLV file is served/created/altered with PHP, get all session
      variables you need straight at the beginning, and call
      session_write_c lose() immediatelly after it before doing any other work.
      After quite a bit of Googling, I've kind of arrived at that position
      myself. :) I put the session_write_c lose() just before the data stream
      is written, and that appears to have solved it.

      But thanks for your input. I arrived at what I thought was the right
      place via a spot of informed guesswork; to have someone then confirm
      that I have indeed arrived in the right place makes me a lot more
      confident in my fix!

      --
      Derek Fountain on the web at http://www.derekfountain.org/

      Comment

      Working...