/    Sign up×
Community /Pin to ProfileBookmark

Can i count All active users by their IP Address?
If not is there any easy way to count currently active users?
please Help to Solve.I’m Stuck.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@bokehDec 14.2007 — Define an active user. Also do you have MySQL?
Copy linkTweet thisAlerts:
@SyCoDec 14.2007 — No not by IP that will only tell you where they are not when. You can track timestamps against ips, or set a cookie and track that against a timestamp. With IPs you can't be sure the IP wasn't re-allocated to another DHCP customer giving you false results. If users log in then track their userid against a timestamp. Personally if I don't know who it is because if there not logged in, then I just track session ids which gives me all the data i need.

So if by currently active you mean users currently on the site then you can record timestamp and session ids into a database table when a user arrives at the site. Either change session auto start in the PHP.ini file or add session_start() to the top of every page you wish to track users in. Create timestamps using time(). Update the timestamps when the users visit a new page. Have a script that runs every x minutes via cron (or schedule task on IIS) that removes old time stamps.

The nice thing about this is you can watch users move through the site in almost real time. If you decide not to delete the users data you set the session ids in one table and relate another table to record the URLs and timestamps. you can set a flag 'active' to 0 against the session when you consider them inactive. You then have loads of data to analyze how users move through your site (when where and for how long) and can tweek your site to better serve them.

The basic principle is record the time since last active and have a auto timed script that runs every x minutes/days/weeks or whatever. Anything longer than an hour (usual session life) will need cookies or a login requirement.
×

Success!

Help @madhu86 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...