Of course you need to include the session part and logVisit() on any page that could/should be reached of the visitor. And after a year or so the logfile might have swelled to 20kB so you might truncated it a little. Set the file permissions for visits.log as it fits your server environment.

coffeedemon

10-28-2003, 12:04 AM

Wasn't supposed to be taken as offensive .

but anyway. do you want this for a personal log?

You can like the above store them in a file or you can use a database and use sessions so you can actual visists rather then hits.

SDP2006

10-28-2003, 12:26 AM

So, mordred, I just need to create visits.log and include it in my index.php page?

Is that all I need to do?

Thanks

mordred

10-28-2003, 12:38 AM

You need to create visits.log in the same directory as index.php, make visits.log writable, and put the PHP code above into your index.php. That's all.

SDP2006

10-28-2003, 01:13 AM

All is well mordred except for this --

Warning: Cannot send session cookie - headers already sent by (output started at /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/index.php:9) in /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/visits.php on line 2

Warning: Cannot send session cache limiter - headers already sent (output started at /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/index.php:9) in /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/visits.php on line 2

Know why?

mordred

10-28-2003, 01:35 AM

You can't have HTML output before the session is started. Move session_start() up in your file that it appears before any HTML (or even a single line break!).

SDP2006

10-28-2003, 02:04 AM

Yay! No more errors! Is it supposed to say "There were 0 visitors yesterday?"

Thanks

mordred

10-28-2003, 11:50 AM

What did you expect? The code just tracks visitors from the time it was installed, and since you did not have it installed yesterday, you can't have any entries for yesterdays visitors... ;)