how to store user login time?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • impin
    New Member
    • Jul 2010
    • 127

    how to store user login time?

    i have created a login system. when the user logged in, the login time is stored... i dont have any problem in that.
    after login the user moved to the user page. in this if the user refresh the page, it stores the current time in the login time...

    so i have multiple login times for the user in the table. how to avoid if the user refresh the page it shouldnt put an entry into the table...
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Each user should use one time. Just to an UPDATE not an INSERT!

    Why do you need to keep all those times? Each time there's a submit update their last_activity_t ime. To check if they're still logged in, make sure X minutes have not passed from this timestamp. And don't use a MySQL DATE TIME field. Use and INTEGER field and just store the Unix epoch time (number of seconds since 1970. See php's time() function.


    Dan

    Comment

    Working...