gpt4 book ai didi

PHP : Keeping track of first login and last logout in mysql

转载 作者:行者123 更新时间:2023-11-29 07:26:34 25 4
gpt4 key购买 nike

我正在做简单的销售应用程序,销售人员登录并不断输入他调用的所有 session /电话的数据。在我的销售人员表中,我必须跟踪当天的第一次和最后一次登录,我真的无法为此开发任何逻辑,我的意思是我如何检测这是否是第一次登录并将其存储在数据库中,然后存储在最后一次当天注销,有人可以帮助我解决逻辑或向我推荐一些链接以浏览一些相关内容

最佳答案

每次登录时执行以下操作:

  • 如果数据库中没有为该天设置“首次登录值”,(创建它)并将其设置为该时间。还将“上次登录值”设置为同一时间。
  • 如果当天已有“首次登录值”,请勿触摸它。只需将“上次登录值”设置为当前时间即可。

可以用下面的伪代码来概括:

// salesman logs in
// check in database first and last login time
if (first-login-time is not set) {
Now set the first-login-time in the database to the current time
}

// you always need to do this
Now set the last-login-time in the database

最终,您要么没有任何值(value)(无法登录)。两个值相同(一次登录)。或者两个不同的值,这将是第一次和最后一次登录时间。

关于PHP : Keeping track of first login and last logout in mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34342317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com