Page 1 of 1
Number of visitors.
Posted: Wed Apr 16, 2008 9:57 pm
by JellyFish
How would I get the number of visitors on a php page? Let's say I have a php page that renders an image that has the number of unique visitors on the page and then saves that image to a location on my server. In order for me to do this I would need a way to count the number of visitors on my page.
How would I do this on the server-side with php?
Thanks for reading.
Re: Number of visitors.
Posted: Thu Apr 17, 2008 6:15 am
by aceconcepts
Would you be counting unique visitors, hits or both?
Re: Number of visitors.
Posted: Wed Apr 23, 2008 7:52 pm
by JellyFish
Only unique. That is, the number of users online.
Re: Number of visitors.
Posted: Thu Apr 24, 2008 3:24 am
by aceconcepts
You would need a comparable variable in a store (like a database). With this comparable variable you would also need something unique for each user (if they are registered users then their ID would work).
Once you have this you could simply compare the two variables to see whether user is has visited - if not then increement "visit variable" and update in database.
Re: Number of visitors.
Posted: Sat Jun 14, 2008 7:36 pm
by JellyFish
Hmm... How would I know when someone has exited my page? If I new of some way to do this I would be able to log when someones online and then log when they're not.
All I really need to be able to do is record when someones visited my page and then record when they've left my page.
What I'll do is count the number of visits and subject the counted number of 'un-visits'.
Re: Number of visitors.
Posted: Sat Jun 14, 2008 11:14 pm
by lonelywolf
maybe you need using session ID to track clients.
Re: Number of visitors.
Posted: Sun Jun 15, 2008 5:28 am
by superdezign
JellyFish wrote:How would I know when someone has exited my page?
You can't know. All you can know is how recently they made a request to the server and received a response from the server. That's the internet for you.
Unless you use Ajax to check their online status constantly, but even that works similarly, just doesn't require any user interaction to accomplish.