470,815 Members | 1,105 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

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_close but not sure.

Thanks
Jul 17 '05 #1
2 1775
On Thu, 06 May 2004 04:09:08 -0700, KhanyBoy wrote:
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_close but not sure.

Thanks


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

http://us3.php.net/manual/en/function.session-unset.php
http://us3.php.net/manual/en/functio...on-destroy.php

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/

Jul 17 '05 #2
KhanyBoy <sh****@unitybusinesssoftware.co.uk> wrote:
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_close but not sure.


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

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by cab | last post: by
4 posts views Thread by Propin | last post: by
4 posts views Thread by anand | last post: by
6 posts views Thread by Martin | last post: by
1 post views Thread by Andy Kasotia | last post: by
11 posts views Thread by David Thielen | last post: by
4 posts views Thread by Chris Ashley | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.