Home > Backend Development > PHP Tutorial > PHP simple setting and deletion of cookie code_PHP tutorial

PHP simple setting and deletion of cookie code_PHP tutorial

WBOY
Release: 2016-07-15 13:22:11
Original
909 people have browsed it

Simple setting and deletion of cookie codes
Cookies are often used in web development to help us deal with some minor problems. Below we have written a simple code for setting and deleting cookies in the PHP cookie function.

/**
  * 设置cookie
   * n 名称
   * c 值
   * e 有效期 0 默认 一个月 1 关闭立即失效
   */


function w_cookie($n, $c, $e = 0,$isdes=1)
 {
   if($isdes==1){$c=endes($c,deskey);}
      $exp = time() + 3600 * 24 * 30;
      if($e == 0)
     {
          setcookie($n, $c, $exp,"/");
     }
     else
     {
      setcookie($n, $c,0,"/");
      }
 }
 
 //关闭cookie方法


 w_cookie('bb', 'www.php100.net', $e = 0,$isdes=1);
 
 //开启设置cookie方法

 
 w_cookie('bb', 'www.php100.net', $e = 1,$isdes=1);


?>
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/447004.htmlTechArticleSimple setting and deletion of cookie code In web development, cookies are often used to help us deal with some minor problems, as follows We wrote a simple setting and deletion of php cookie function...
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