However, this mechanism will always bring us this or that problem. For example, some time ago, when I set an advertisement display function on my site, I needed cookies, the main purpose is to increase the conversion rate of the advertisement. However, if the refresh takes effect, it is troublesome. Therefore, this method is used for ease of use.
The following code is used:
Copy codeThe Code is as follows:
Function cookie ($ var, $ value = '', $ time = 0, $ path ='', $ domain = ''){
$ _ COOKIE [$ var] = $ value;
If (is_array ($ value )){
Foreach ($ value as $ k => $ v ){
Setcookie ($ var. '['. $ k. ']', $ v, $ time, $ path, $ domain, $ s );
}
} Else {
Setcookie ($ var, $ value, $ time, $ path, $ domain, $ s );
}
}
// Call Method
Cookie ("website", "WEB Development notes", "./", "www.jb51.net ");
//
Echo $ _ COOKIE ["website"]; // output WEB Development notes