Home > Backend Development > PHP Tutorial > PHP cookie does not refresh the implementation code that takes effect in a timely manner

PHP cookie does not refresh the implementation code that takes effect in a timely manner

WBOY
Release: 2016-07-25 09:00:08
Original
1259 people have browsed it
  1. /**
  2. * Do not refresh the cookie to take effect in time
  3. * site http://bbs.it-home.org
  4. */
  5. cookie("mycookie","cookievalue",time()+60);
  6. var_dump($_COOKIE["mycookie"]);
  7. //PHP COOKIE setting function takes effect immediately, supports arrays
  8. function cookie($var, $value='', $time=0, $path='', $domain='')
  9. {
  10. $_COOKIE[$var] = $value;
  11. if(is_array($value)){
  12. foreach($value as $k=>$v){
  13. setcookie($var.'['.$k.']', $v, $ time, $path, $domain, 0);
  14. }
  15. }else{
  16. setcookie($var, $value, $time, $path, $domain, 0);
  17. }
  18. }
  19. ?>
Copy the code

For those who are interested, you can learn about: Cookie and Session usage in php5.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template