Home  >  Article  >  php教程  >  php简单设置与删除cookie代码

php简单设置与删除cookie代码

WBOY
WBOYOriginal
2016-06-13 10:59:111733browse

简单设置与删除cookie代码
在web开发中经常会用到cookie来帮我们处理一些小问题,下面我们就写了一个简单的关于php cookie函数的设置与删除cookie的代码。

/**
  * 设置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);


?>

Statement:
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