Hello. I know that many people are already blessed with PHP5. Unfortunatly, not bieng one of them, I still have to do my code in PHP4, and came accross needing to use a destructor.
Basically, I have a user class that's stored in the $_SESSION[] autglobal. When the user logs out or leaves the site or closes the window, I need PHP to do a query to SQL database. I know of register_shutdown_function(), but I don't really understand how to use it. Can someone please give me a pointer? Thanks!
Class clean up (Destructor) in PHP4
Moderator: General Moderators
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
right, and that's how probably many of us have done it..
Basically, here's how I have my who's online setup.. (similar to phpbb)
when someone, anyone, accesses a page, the session table is looked at.. any sessions older than (enter your max life limit here) is deleted.. then you count how many were updated in the last (enter your "online" life span here)..
Basically, here's how I have my who's online setup.. (similar to phpbb)
when someone, anyone, accesses a page, the session table is looked at.. any sessions older than (enter your max life limit here) is deleted.. then you count how many were updated in the last (enter your "online" life span here)..
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
How do I measure the life of a session? And what if a user is on longer than some time? Not exctly accurate data because if someone is on for 5 minutes, and the session lasts 3 hours (like you suggested), it is inacurate. At the same time, if someone spends 12 hours on my site (not likely, but hey), they'd end up getting shown as offline after 3 hours. 
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
store a start time, and last update/access time.. each page updates the last time field.. you can tell how long they've been online, and how recently they've looked at a page.
the who's online should only look for people active (last access time) is less than 5 or 10 minutes old.. something like that..
so most of your checks would run off the last access time field..
the who's online should only look for people active (last access time) is less than 5 or 10 minutes old.. something like that..
so most of your checks would run off the last access time field..
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada