Visitors Online
Moderator: General Moderators
Visitors Online
does anyone know the neat trick that enables a veiwing of the current visitors online on the page? thx!
I have seen one solution that stores a username and a timestamp in a table when the user accesses to site. The timestamp gets updated everytime the user loads a new page. Then there are a cron job running every now and then wich removes users no longer at the site (read with an old timestamp).
Then it's just to count how many rows there are in the table and there you have how many users currently online. This way you can list which users you have online as well.
If you don't use usernames you can use the clients ip- or hostname.

Then it's just to count how many rows there are in the table and there you have how many users currently online. This way you can list which users you have online as well.
If you don't use usernames you can use the clients ip- or hostname.
haagen described the most common way to do it. however, instead of a cron job, you can have the cleanup process be handled in the page load (this is especially effective if you don't have access to cron).
it doesn't matter if entries stay in the table for extended periods of time because as soon as someone visites the site (the only time the table's contents really matter) then the table will be cleaned up.
just make sure you do the cleanup before building a list of current users.
it doesn't matter if entries stay in the table for extended periods of time because as soon as someone visites the site (the only time the table's contents really matter) then the table will be cleaned up.
just make sure you do the cleanup before building a list of current users.
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
The only way to get good at programming, IMHO, is to forget what is 'newbie friendly', pick a poject (this seems like a pretty good one), and get obsessed with it. Do it yourself, ask questions if you really get stuck, but roll up your sleeves and spend a few nights coding for real.
In my experience, just when you're ready to tear your hair out, you'll have a flash and it'll all come to you. That high is why I'm addicted to programming, and maybe you'll catch it too
In my experience, just when you're ready to tear your hair out, you'll have a flash and it'll all come to you. That high is why I'm addicted to programming, and maybe you'll catch it too
yea i relized that exactally too! 
but what i find the most "hard to stomach" is the fact that no site i've seen so far has any step by step learning of the basics, even the book i have doesn't give me enough detail to what i want to learn.
I know there is a place somewhere, where people learn how to do all these crazy things i've been seeing on some of your sites, i just want to know where it is so i can get a cut in on the action, if ya know what i mean
but what i find the most "hard to stomach" is the fact that no site i've seen so far has any step by step learning of the basics, even the book i have doesn't give me enough detail to what i want to learn.
I know there is a place somewhere, where people learn how to do all these crazy things i've been seeing on some of your sites, i just want to know where it is so i can get a cut in on the action, if ya know what i mean
- Johnm
- Forum Contributor
- Posts: 344
- Joined: Mon May 13, 2002 12:05 pm
- Location: Michigan, USA
- Contact:
Oromian,
It is helpful to understand the basic concepts of programming. Not knowing you age/employment makes it hard to give good advice but if you can, take some intro programming courses at the local University. A few short courses in C++ will give you the basic tools you need. After that, necessity drives invention.
Direwolf
It is helpful to understand the basic concepts of programming. Not knowing you age/employment makes it hard to give good advice but if you can, take some intro programming courses at the local University. A few short courses in C++ will give you the basic tools you need. After that, necessity drives invention.
Direwolf