Ubiquity  2.0.0
php rapid development framework
CookieUtils.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Ubiquity\utils;
4 
10 class CookieUtils {
18  public static function set($name,$value,$duration=60*60*24,$path="/"){
19  \setcookie($name, $value, \time() + $duration,$path);
20  }
21 
28  public static function get($name,$default=null){
29  return isset($_COOKIE[$name])?$_COOKIE[$name]:$default;
30  }
31 
37  public static function delete($name,$path="/"){
38  \setcookie($name, "", \time() - 3600,$path);
39  }
40 
44  public function deleteAll($path="/"){
45  foreach ($_COOKIE as $name=>$value){
46  self::delete($name,$path);
47  }
48  }
49 }