1、PHP自己的框架cookie()
2、cookie类(CookieBase.php)
<?php
class CookieBase
{/*** 设置cookie*/public static function set($name, $value, $expire = 3600, $path = '', $domain = '', $secure = false, $httponly = false) {setcookie($name, $value, $expire+time(), $path, $domain, $secure, $httponly);}/*** 读取cookie*/public static function get($name) {if (isset($_COOKIE[$name])) {return $_COOKIE[$name];}return null;}
}
3、封装cookie类function.php
function cookie(){$num=func_num_args();$cookie=new CookieBase();if($num>=2){if($num==3){//三个参数$expire=func_get_arg(2);}else{//二个参数$expire=3600;}$cookie::set(func_get_arg(0),func_get_arg(1),$expire);return true;}else{//一个参数return $cookie::get(func_get_arg(0));}
}
4、调用cookie(indexCrl.php)
<?php
class indexCrl{public function index(){//设置cookiecookie('name','haha',60);//获取cookiecookie('name');//清空cookiecookie('name',null);}
}