views:

61

answers:

3

Is there a way to find out on session being started. Like for instance the session start event in the global.ascx file of .net. The requirement is to find the no. of visits the user has done on the site.

Instead of checking each time during posts or gets to the server. Is there something in php to find out if the session is a new one. Zen framework is also used for the app.

+1  A: 

You can actually mimic what is done by global.ascx file through php and also there are a number of scripts available online for tracking online users you need to google about that.

Sarfraz
A: 

you can use memcache for that purpose, or simply hack with a file(mentioned on Safraz answer) on the disc, or use a table on your database for that purpose.

Memcache appears to me the best solution since it is easy to setup and they already provide counter with increment/decrement. The only drawback of this solution your won't be able to reset the counter easily.

RageZ
+1  A: 

Zend_Session::isStarted() and Zend_Session::sessionExists() will tell you if the session is already started. To find out when it was started for the first time, you could store the timestamp it was created, by adding it to the session on the very first startup. Just check if a key started_at already exists in the Session and if not add it and/or notify some other class about it to do something.

Gordon