Why is the return time of the cookie incorrect? Solution

Source: Internet
Author: User
Why is the return time of the cookie incorrect? & Lt ;? Php first checks whether the cookie contains information about the last logon. if (! Empty ($ _ COOKIE [lastvisit]) {echo & quot; your last logon time was & quot ;. $ _ COOKIE [lastvisit]; update time setcookie (& quot; lastvisit & quot;, why is the returned Time of dat cookie incorrect?
// First, check whether the cookie contains the last logon information.
If (! Empty ($ _ COOKIE ['lastvisit']) {

Echo "the last time you log on is". $ _ COOKIE ['lastvisit'];
// Update time
Setcookie ("lastvisit", date ("Y-m-d H: I: s"), time () + 600 );
} Else {
Echo "this is your first logon ";
Setcookie ("lastvisit", date ("Y-m-d h: I: s"), time () + 600 );
}
?>
The time I returned was totally different from the time on my computer system.
I set the time zone, and it is useless to set the time zone to the Chongqing time zone. The time has not changed at all.
What's next?

------ Solution --------------------
Setcookie ("lastvisit", date ("Y-m-d H: I: s"), time () + 600 );

Setcookie ("lastvisit", date ("Y-m-d h: I: s"), time () + 600 );

There is a difference.

------ Solution --------------------
Powerful upstairs.
------ Solution --------------------
It seems that one is a 24-hour system and the other is a 12-hour system.
------ Solution --------------------
Time format problems.
------ Solution --------------------
Not good, not good ..

Security should be considered when data is stored on the client, although there is no security problem.
------ Solution --------------------
The reason for your problem is that you need to setcookie before you can echo ......


In addition, the problem lies in #1.

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.