Visitors Now Online
Moderator: General Moderators
Visitors Now Online
I need to know how can I track current guest visitors to my site and display it in the top of the page,
what functions do I need?
Is database needed for this? or can I use a text file?
what functions do I need?
Is database needed for this? or can I use a text file?
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Visitors Now Online
I use a database and it work perfectly for me.
You would need to update a database specific to a user's activity and thenset a $_SESSION[] variable as their status i.e. logged in
You would need to update a database specific to a user's activity and thenset a $_SESSION[] variable as their status i.e. logged in
Re: Visitors Now Online
Code: Select all
$count = `ls -l /var/lib/php5/ | wc -l`No DB, no file, nothing ... just Linux cmd shell
PS: "/var/lib/php5/" is for the value of session.save_path in php.ini
Last edited by VladSun on Mon Jun 27, 2011 3:29 pm, edited 1 time in total.
There are 10 types of people in this world, those who understand binary and those who don't
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Visitors Now Online
I like. One line of code 
Re: Visitors Now Online
Well, it's not ideal:
- it depends on session.gc_maxlifetime;
- it's for session management that uses file storage;
Also, there is an issue (bug?) - there is always one session file left in this directory, regardless of any *maxlifetime;
- it depends on session.gc_maxlifetime;
- it's for session management that uses file storage;
Also, there is an issue (bug?) - there is always one session file left in this directory, regardless of any *maxlifetime;
There are 10 types of people in this world, those who understand binary and those who don't
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Visitors Now Online
I guess it also depends on the extent to which one will be taking "user tracking".
If you want to log user activity etc... then a database would be ideal.
If you want to log user activity etc... then a database would be ideal.
Re: Visitors Now Online
I cannot exactly figure out this,
lets say that user comes to my home page, then I will initialize a session like this $_SESSION['user'] = "Guest";
Now the problem is that how can I find all initialized $_SESSION['user'] from my server?
Then how do I know user left the my site?
lets say that user comes to my home page, then I will initialize a session like this $_SESSION['user'] = "Guest";
Now the problem is that how can I find all initialized $_SESSION['user'] from my server?
Then how do I know user left the my site?
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Visitors Now Online
you can use a session id to keep track of unique guests
With regard to the guest leaving the site, this has been asked quite a few times - and well there is no way to acurately determine when a visitor leaves the site unless they log out.
However, the default lifetime of a session is 24minutes so i guess this solves your problem.
With regard to updating the database you would probably have to check the guest's session validity at a set time i.e. every 30 minutes etc...
Code: Select all
$_SESSION['guestId']=session_id();
However, the default lifetime of a session is 24minutes so i guess this solves your problem.
With regard to updating the database you would probably have to check the guest's session validity at a set time i.e. every 30 minutes etc...
-
suresh_2220
- Forum Newbie
- Posts: 23
- Joined: Mon May 12, 2008 3:13 pm
Re: Visitors Now Online
You can add third party software (javascript code) inside your code. there is no need for any DB or txt file. the third party software will store visitor details in their server and result will display in your site. Please visit this URL http://www.google.co.in/search?hl=en&q= ... nter&meta=