Cookie implementation shows questions about the last logon time

Source: Internet
Author: User
Cookie implementation displays the last logon time issue
An account login can display the last logon time, but after changing to another account login,
The logon time displayed is the time of the previous account, do not know what method to solve?
------Solution--------------------
Do you mean to show the last login time?
------Solution--------------------
Or use a database, and if you change a computer, you won't get it.
Of course on a computer, you can use the user's ID to set the cookie key value, after the user login, according to the returned ID to obtain the corresponding cookie
------Solution--------------------
Change the machine, the cookie is not the same, there is no way to synchronize, through the database table storage time, you can solve.
------Solution--------------------
The cookie name with the user ID resolves the issue.

Write cookies
$cookie _name = $uid + ' lastlogintime ';
$cookie _value = time ();
$cookie _expire = time () +31536000;
Setcookie ($cookie _name, $cookie _value, $cookie _expire);

Read cookies
$cookie _name = $uid + ' lastlogintime ';
$lastlogintime = $_cookie[$cookie _name];
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.