计数和回显总计$ _SESSION [关闭]
问题描述:
How do I count how many times the users use/login $_SESSION
and echo the total system count? (Assuming $_SESSION['login
])
Thanks in advance.
如何计算用户使用/登录 提前致谢。 p>
div> $ _ SESSION code>的次数并回显 总系统数量? (假设
$ _ SESSION ['login code>]) p>
答
You could store it in a $_SESSION
variable but it's unreliable and users could easily reset the session cookie. I'd do something like this instead:
if (user_logged_in)
{
$query = "UPDATE some_table SET total_logins = total_logins + 1 WHERE user_id = $userID";
$mysqli->query($query) or die($mysqli->error);
}
Hope this helps!