PHP equiv of Session_OnEnd in ASP

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

    PHP equiv of Session_OnEnd in ASP

    Is there a function to fire an event when a php session ends? When
    this event is fired, I want to make some change to a database before
    losing the session data.

    I have a feeling it will involve session_write_c lose but not sure.

    Thanks
  • Jeffrey Silverman

    #2
    Re: PHP equiv of Session_OnEnd in ASP

    On Thu, 06 May 2004 04:09:08 -0700, KhanyBoy wrote:
    [color=blue]
    > Is there a function to fire an event when a php session ends? When
    > this event is fired, I want to make some change to a database before
    > losing the session data.
    >
    > I have a feeling it will involve session_write_c lose but not sure.
    >
    > Thanks[/color]

    Take a look at session_destroy () and session_unset() ;

    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.

    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


    I'm pretty sure a session ends one of two ways: session_destroy ()
    (manually ending a session) or the browser is closed.

    I don't think PHP sessions end quite the same way as ASP sessions, but I'm
    not certain. You pretty much will always have the session data available
    as long as you have session_start() at the top of each relevant PHP
    script. The session is tied to the web browser -- an id based on some
    unique parameters having to do with the particular browser instance. As
    long as the browser is open, the session is intact for every page with
    session_start() at the top of the page.

    In order to save session data permanently, you have to do something with
    it before the end of the script. Each PHP page is treated separately.

    Not sure if this clears anything up for you.

    --
    Jeffrey D. Silverman | jeffrey AT jhu DOT edu
    Website | http://www.wse.jhu.edu/newtnotes/

    Comment

    • Daniel Tryba

      #3
      Re: PHP equiv of Session_OnEnd in ASP

      KhanyBoy <sharif@unitybu sinesssoftware. co.uk> wrote:[color=blue]
      > Is there a function to fire an event when a php session ends? When
      > this event is fired, I want to make some change to a database before
      > losing the session data.
      >
      > I have a feeling it will involve session_write_c lose but not sure.[/color]

      IMHO the best thing to do is write your own sessionhandler
      (http://us3.php.net/manual/en/functio...ve-handler.php) and
      do yourstuff (tm) in the destroy method.

      --

      Daniel Tryba

      Comment

      Working...