Is there is Session_OnEnd event ON php Like asp

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pramod
Forum Newbie
Posts: 10
Joined: Mon Oct 25, 2004 6:28 am
Location: ind
Contact:

Is there is Session_OnEnd event ON php Like asp

Post by pramod »

Is there is Session_OnEnd event ON php Like asp ,

if not how can I get a session end time (If there is no proper shut down or connection cut).

Any one have idea about this please help me


Thank u .

Pramod .K.V.P
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

Php clear the sessions after a timeout, so you dont need to do it if you are using sessions like php handles it.

If you are using sessions withing a DB you need to do the cleanup manually (with a cron)
pramod
Forum Newbie
Posts: 10
Joined: Mon Oct 25, 2004 6:28 am
Location: ind
Contact:

Post by pramod »

My actual requirement is that .

when client request to my page the i will start a infinate loop to get the aproximate time he is conected with that page . I want to sto the execution of that script when the client close the browser or go to next page or click on stop button of browser .

Please help me to solve the situation.
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

You dont need to make an infinite loop.

When your client request you page, save a timestamp for that user (you can do it un a Database, use the session id to identify the user, or some source of authentication method).

You cant have the moment when the user close the browser with php. What you can do, is register their last activity. In every page the user open you can put a function that update the record of the timestamp.

A table un the DB:
ClientID - TimeStampStart - TimeStampLastActivity.

Or you can make all your script like this:

http://mysite.com/go.php?url=newlink.php

and do the trick in go.php, and after you update that record, just redirect the browser to newlink.php


Hope it helps.

(Damn, i was writing this and when i submit it: phpBB Critical error, cant connect to DB. ) :(
Post Reply