PHP determines whether or not the user is online

time:15-07-29 forum:PHP tools and code
  The [code]session_start ();
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / > 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;

prev:Insert video ads before Js video playbac... next:PHP automatically identifies links in te...
post comment
Notice



approved   Wearing 35 yuan clothes and feeding ...   The age of mortgage repayment is rai...   What do you do with a baby crying ou...   39 years old as a girl! Takizawa Mak...   Have you ever eaten steamed pagoda f...
rand   PHP determines to compare the data i...   PHP opens TXT, writes to Mysql, invo...   PHP reads the MYSQL contents into tw...   How do you grab and analyze the page...   Processing techniques for PHP passin...
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com