The usage analysis of cookie method in thinkphp3.x, Thinkphp3.xcookie
This paper analyzes the usage of cookie method in thinkphp3.x. Share to everyone for your reference, as follows:
The cookie function is also a diversified operation function, which completes the setting, fetching and deleting of cookies.
Cookies are used for cookie settings, acquisition, and deletion operations:
Usage:
Cookie ($name, $value = ", $option =null)
Parameters:
Name (required): Cookie variable to manipulate
Value (optional): The cookie value to set
Option (optional): Incoming cookie setting parameter, default is empty
Return values See details (return different values depending on the specific usage)
Second, cookie settings
Cookie (' name ', ' value '); Set Cookiecookie (' name ', ' value ', 3600); Specify the cookie save time
Starting with version 3.1, the cookie method adds support for arrays (saving less storage space in a lightweight JSON encoded format), such as:
Cookie (' name ', Array (' name1 ', ' name2 '));
You can also support the way in which parameters are passed in to complete complex cookie assignments, the following is a 3,600-second validity period for the value of the cookie, plus a cookie prefix THINK_
Cookie (' name ', ' value ', Array (' Expire ' =>3600, ' prefix ' = ' think_ '))
Array parameters can be used as query form parameter
Cookie (' name ', ' value ', ' expire=3600&prefix=think_ ')
is equivalent to the above usage.
The incoming option parameter supports Prefix,expire,path,domain four index parameters, and defaults to Cookie_prefix, Cookie_expire, Cookie_path, and cookies if there are no incoming or empty values passed in. _domain four configuration parameters. If only individual parameters are passed in, they are also merged with the default configuration parameters.
Third, cookie access
Getting a cookie is simple, no matter how the cookie is set, only needs to use:
$value = Cookie (' name ');
If the cookie prefix is not set, the equivalent
$value = $_cookie[' name ']
If a cookie prefix is set, the equivalent
$value = $_cookie[' prefix +name ']
Iv. Deletion of cookies
To delete the value of a cookie, use:
Cookie (' name ', null);
To delete all cookie values, you can use the
Cookie (NULL); Clears all cookie value cookies for the current set prefix (null, ' think_ '); Clears all cookie values for the specified prefix
PS: Here are recommended several of the format of the site landscaping tools, I believe that we can use in the future development:
PHP Code online format Beautification tool:
Http://tools.jb51.net/code/phpformat
JavaScript code beautification/compression/formatting/encryption Tools:
Http://tools.jb51.net/code/jscompress
Online XML format/compression tool:
Http://tools.jb51.net/code/xmlformat
JSON Code formatting beautification tool:
Http://tools.jb51.net/code/json
Online Xml/json Mutual Conversion tool:
Http://tools.jb51.net/code/xmljson
SQL code online Format beautification tool:
Http://tools.jb51.net/code/sqlcodeformat
More interested in thinkphp related content readers can view this site topic: "thinkphp Introductory Tutorial", "thinkphp Common Method Summary", "PHP Cookie Usage Summary", "Smarty Template Primer Basic Tutorial" and "PHP template technology Summary."
It is hoped that this article is helpful to the PHP program design based on thinkphp framework.
http://www.bkjia.com/PHPjc/1127837.html www.bkjia.com true http://www.bkjia.com/PHPjc/1127837.html techarticle The usage analysis of cookie method in thinkphp3.x, Thinkphp3.xcookie the usage of cookie method in thinkphp3.x in this paper. Share to everyone for your reference, as follows: First, cook ...