简体   繁体   English

如何在我的用户存储在SQL数据库中的网站上记录每个用户的时间会话?

[英]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: 我需要更准确的是:

  • How many times they logged in for the month 他们一个月登录了多少次
  • Average duration of logins for the month 本月平均登录时间

Example: 例:

  • User A has logged in the website 200 times this month 用户A本月已登录该网站200次
  • User A session duration each visit on average 5 minutes 用户A会话持续时间,每次访问平均5分钟

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.

相关问题 如何检查用户是否通过 facebook 登录或网站登录系统 - how do I check if users login via facebook or website log in system 如何创建允许网站用户向我的网站添加页面的功能? - How do i create functionality for allowing website users to add a page to my website? 如何阻止用户在一天的特定时间访问我的网站的一部分? - How can I block users from accessing a section of my website at a specific time of day? 多个应用程序,一个数据库。 如何为用户进行跨会话? - Multiple apps, one database. how to do cross session for users? $_SESSION 登录脚本:不验证 SQL 数据库中的用户 - $_SESSION login script: not validating users in SQL database 如何在我的网站上为许多用户创建链接但指向相同的模板页面? - How do I make a link on my website for many users but pointing to the same template page? 如何整合google登录我的网站并收集用户详细信息? - How do I integrate google sign in to my website and collect the users details? 即使有用户访问我的wordpress网站,也会出现视频弹出窗口,该怎么办? - wheneven users visit my wordpress website, video popup appears , How should i do that? 如何允许 iOS 用户通过我网站上的 html 输入字段上传文档? - How do I allow iOS users to upload a document via an html input field on my website? 我需要在数据库中为每个用户信息提供一个表吗? - Do I need a table in my DB for each users info?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM