[英]How do I log each users time session on a website where my users are stored in an SQL Database?
I have a basic website made with html/css/php. 我有一个使用html / css / php制作的基本网站。 There is a login page that requires a username and password to access all other areas of the website.
有一个登录页面,需要用户名和密码才能访问网站的所有其他区域。 The users are stored in a MySQL Database (fields: username, password, store, etc).
用户存储在MySQL数据库中(字段:用户名,密码,存储等)。
I need/want to be able to view when the user logged in and how long that particular user was logged in for. 我需要/想能够查看,当用户在多长时间特定的用户登录在登录。 I need a simplified way to show this data to someone who would not have access to the cpanel.
我需要一种简化的方法来向无法访问cpanel的人显示此数据。
Sorry for such a vague question, feel free to abuse me and ask for more info and I will reply with what's needed and asked of. 很抱歉遇到这样一个模糊的问题,请随时虐待我并询问更多信息,我将回答需要和提出的问题。
EDIT: Sorry I would like to re-phrase what I've asked for as I think having every individual login sessions would make this log quite too much. 编辑:对不起,我想重新解释一下我的要求,因为我认为每个单独的登录会话都会使此日志变得太多。 What I need more accurately would be:
我需要更准确的是:
Example: 例:
Sorry for the confusion. 对困惑感到抱歉。 The examples above would be the data needed.
上面的示例将是所需的数据。
You can save timestamp when a user login and logout. 您可以在用户登录和注销时保存时间戳。
$logintime = date('Y-m-d H:i:s');
$logout_time = date('Y-m-d H:i:s');
Keep these data in a log table. 将这些数据保存在日志表中。 The difference between this timestamp give the duration.And each tim a person login the value of a feild 'no_of_times' (type:integer,default:0) can be increase +1.
此时间戳之间的差异给出了持续时间。每个登录时间的人都可以将“ no_of_times”(类型:整数,默认值:0)的值增加+1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.