/*
* When no verification code is involved
*/
Count the number of visitors (not logged in)
$map = Array (' Session_expire ' =>array (' GT ', now_time), ' Session_data ' =>array (' eq ', ') '); $youke = D (' Session ')- >where ($map)->count ();d UMP ($youke);
Count members (logged in)
$map = Array (' Session_expire ' =>array (' GT ', now_time), ' Session_data ' =>array (' neq ', ') '); $huiyuan = D (' session ') ->where ($map)->count ();d UMP ($huiyuan);
Total number of online statistics
$map = Array (' Session_expire ' =>array (' GT '), now_time), $inline = D (' session ')->where ($map)->count ();d UMP ($ inline);
Add the SessionID field to the user table, log the login SessionID, and determine if a user is online
$session _id = session_id (), $map = Array (' session_id ' = $session _id, ' Session_expire ' =>array (' GT ', now_time), ' Session_data ' =>array (' neq ', ')); $res = D (' Session ')->where ($map)->find (); if ($res) dump (' The user is online. '); else dump (' The user is not on the line. ‘);
The verification code will also be stored in the session, so when we judge it, we cannot count the value of the record.
You need to get the value of the data first, and then determine if there is no user information stored in the parameter name. Although the Session_data field is stored in binary, the query is a string.
Session (' user ', $data);//User login information
Get real number of members
Query the session record with value
$list = D (' Session ')->where (Array (' Session_data ' =>array (' NEQ ', '), ' Session_expire ' =>array (' GT ', Now_time ))->select ();d UMP ($list);//Determine if there is a member ID $count=0;foreach ($list as $k = $value) {if (Strpos ($value [' Session_ Data '], ' user ') {$count + +;}} Dump ($count);//true number of members
Session Statistics Online Number