Home  >  Q&A  >  body text

How to update login times and time

How to design the database to update these two

搜狗截图18年03月30日1652_1.png搜狗截图18年03月30日1656_3.png

Fan searFan sear2417 days ago1554

reply all(6)I'll reply

  • 铭德科技

    铭德科技2018-03-30 17:24:20

    I'm wrong. This variable has a key that stores user information. The key is not the user variable but the session

    reply
    0
  • Fan sear

    Is it possible to update the value of login_time in the database in the method of logging out? The next time you log in, you will get the updated number.

    Fan sear · 2018-03-30 19:49:17
    Fan sear

    Wrong, it's login_count

    Fan sear · 2018-03-30 19:52:56
    铭德科技

    Yes, just add 1 to the count stored in the database before exiting (clearing the session)

    铭德科技 · 2018-03-31 09:18:28
    铭德科技

    public function exitFun(){ //Find the session data that stores the user based on the user_id of the user session. The yyy method is to obtain the data. $res = model('xxx')->yyy($user_id); //The number of times obtained plus the number of logins equals the new number of times $count = $res['count'] +1 //Execute to update the new number $count to the corresponding user's login times $newRes = model('xxx')->zzz($user_id,$count); //Clear SESSION after completion and launch login //This is only in the controller, the data layer should be fine }

    铭德科技 · 2018-03-31 09:26:58
  • 铭德科技

    铭德科技2018-03-30 17:22:15

    Judging from {$Think.session.user_info.login_count}, a template variable $Think should be passed from the controller. This variable is the session that stores user information. So there should be a field in the table to store the session, and the session is updated every time you log in

    reply
    0
  • Cancelreply