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

php简单设置与删除cookie代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:59:11
Original
1804 people have browsed it

简单设置与删除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);


?>
Copy after login

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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template