-
- /**
- * Do not refresh the cookie to take effect in time
- * site http://bbs.it-home.org
- */
- cookie("mycookie","cookievalue",time()+60);
- var_dump($_COOKIE["mycookie"]);
-
- //PHP COOKIE setting function takes effect immediately, supports arrays
- 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, 0);
- }
- }else{
- setcookie($var, $value, $time, $path, $domain, 0);
- }
- }
- ?>
-
Copy the code
For those who are interested, you can learn about: Cookie and Session usage in php5.
|