Ask a php question about setting the cookie validity period

Source: Internet
Author: User
I have set a cookie in php as follows: setcookie ("cookie_name", & nbsp; "abcd", & nbsp; time () + 3600); this means that the cookie has a validity period of 3600 seconds. if I have a question about setting the cookie validity period in php at 300th
In php, I set the cookie as follows:

Setcookie ("cookie_name", "abcd", time () + 3600 );

This means that the cookie has a validity period of 3600 seconds. if I refresh the page at 3,000th seconds, then the cookie has a validity period of 3600 seconds again, or 600 seconds left? Share:
------ Solution --------------------
Cookie validity period starts to take effect when it is out of scope
------ Solution --------------------
There are another 3600 seconds. when setting a cookie, you will not consider whether the previous cookie and cookie settings are valid. you can think of them as mandatory settings.
------ Solution --------------------
You just need to think about the program going to this line and executing the code again.
------ Solution --------------------
It doesn't matter if you refresh the page. it starts from the first time you open the page and execute code. if you close the browser, re-open and re-calculate (of course, this requires php. ini sets the switch to disable the browser and immediately expire. In fact, the switch starts when the page is opened and cokeie is generated. if you open the page and the cokeie is generated for 1800 seconds, if the set 3600 seconds fails, refresh the page for 1800 seconds.

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.