How to use setcookie

Source: Internet
Author: User
Please refer to the usage of setcookie. if I want to keep COOKIES permanently, how can I use setcookie to implement a large value for expire? In addition, if you want to save for one month, it will be 60*60*24*30 in 30 days. Is there any precise calculation method ?, In short, cookies cannot be stored permanently. store things. you need to store the data to ask about setcookie usage.
If I want to keep COOKIES permanently
How can I use setcookie to implement a large value for expire?
In addition, if you want to save for one month, it will be 60*60*24*30 in 30 days. Is there any precise calculation method?

------ Solution --------------------
In short, cookies cannot be stored permanently. you need to store data in the database.
Cookie: you can store the ID of the user information, and retrieve it from the database when necessary.
Convenience, and no vulnerabilities are generated.
There are also cookies,
Important data must be encrypted
------ Solution --------------------
60*60*24*30 is an expression. The final input parameter is 2592000.
It is easy to read, 3600 seconds per hour, 24 hours per day, and 30 days per month.
As for what you said, if you consider the actual number of days per month, it will be a little troublesome. you can search for. PHP to get the actual number of days per month.
------ Solution --------------------
Bool setcookie (string name [, string value [, int expire [, string path [, string domain [, bool secure])

The time when the expire Cookie expires. This is a Unix timestamp, that is, the number of seconds from the Unix epoch. In other words, the time () function and the number of seconds are usually used to set the cookie failure period. Or use mktime. Time () + 60*60*24*30 will set the cookie to expire after 30 days. If not set, the cookie will expire after the session ends (usually closed by the browser ).

This is the case after the setcookie is executed. if the user executes the setcookie once each time, will it be permanent?
------ Solution --------------------
Why do you have to write a cookie after logging on?
Why can't I write cookies when verifying that the logon information is valid?

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.