PHP determines whether or not the user is online
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / > if the username exceeds the specified time the field is not updated
below is a simple example:
$conn=.quot;.Quot; A variable link database
database table: 'new' field: 'name', 'time'
$name= 'annen network 1';
$select=mysql_query (.Quot; select*from new); ) {echo 'current user' online ';}else{echo' current user off-line;}
$name= 'annen network 2';
$select=mysql_query (.Quot; select*from new where name= '$name'); Browse website ';}else{echo' current user offline ';}
if the user stays on the page, JS automatically updates the online state var g=1; while (g.lt; 5) {var anlin=g*5000; setTimeout (loadXMLDoc (), Anlin); / / / / / / / / / {/ / / / code for IE7, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest (); .quot;} var urll=.quot; URL address.Quot; xmlhttp.open (.Quot; GET.quot; urll, true); xmlhttp.send (}
Ysql_fetch_array ($select);
if ($fetch.#91; time.#93; 60.gt; time ()) {exit ('current user has logged in');}else{$_SESSION.#91; 'name'.#93;