Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   how to dis visitor online(php) (http://www.go4expert.com/forums/dis-visitor-online-php-t24967/)

reimo 14Feb2011 14:05

how to dis visitor online(php)
 
please i need a help, i want a php script that help me display the numbers of visitors in my site and to display logged in users and guest.
thank for being of help.

underground_devil 19Feb2011 10:39

Re: how to dis visitor online(php)
 
i can make it according to need because its long script so i cant be send here :)

ManzZup 25Feb2011 20:00

Re: how to dis visitor online(php)
 
as this is something exactly i was doing for the past few days i can help :D
as i figured, the best and the easiest way to achieve this is using Jscript, where a periodical updator will update the the availability of the user
this is okay for ma chat script, but i dunno whether its okay with you, but i assure that it's mostly accurate than the previous method i used: of keeping the track of the user using a cookie and the work done by the user

but sorry im in a kindda hurry
so basically the logic is,
when the user sign in-> you take him to a new page ex:homepage
then the user is added to the online table
and in the header of the site, you put the update code, or a jS AJAX request every 30sec. to update the time() of the database

and peridically, add another check, mostly a AJAX request to delete the records which have the time() filed updated more than before 1 minute

so that's it :DD
hope you understand, and the code is rather simpler and may be you can figure it out yourself
however ill write it seperatly later [i ave it with the core files of the chat scirpt so that it takes time to make it as standalone] :D

pein87 9Mar2011 03:50

Re: how to dis visitor online(php)
 
You need to set up either a session for every person or a cookie and have each time one is created stored in an array based on its user type. Then count each array's length for the total. Once it expires though you need to remove that index from the stack.


All times are GMT +5.5. The time now is 17:30.