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.
Number of visitors.
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Number of visitors.
Would you be counting unique visitors, hits or both?
Re: Number of visitors.
Only unique. That is, the number of users online.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Number of visitors.
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.
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.
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'.
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'.
- lonelywolf
- Forum Commoner
- Posts: 28
- Joined: Tue Jun 10, 2008 6:15 am
Re: Number of visitors.
maybe you need using session ID to track clients.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: Number of visitors.
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.JellyFish wrote:How would I know when someone has exited my page?
Unless you use Ajax to check their online status constantly, but even that works similarly, just doesn't require any user interaction to accomplish.