Ubiquity  2.0.3
php rapid development framework
UCookie.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Ubiquity\utils\http;
4 
10 class UCookie {
11 
19  public static function set($name, $value, $duration=60*60*24, $path="/") {
20  \setcookie($name, $value, \time() + $duration, $path);
21  }
22 
29  public static function get($name, $default=null) {
30  return isset($_COOKIE[$name]) ? $_COOKIE[$name] : $default;
31  }
32 
38  public static function delete($name, $path="/") {
39  if(isset($_COOKIE[$name])){
40  unset($_COOKIE[$name]);
41  }
42  \setcookie($name, "", \time() - 3600, $path);
43  }
44 
48  public function deleteAll($path="/") {
49  foreach ( $_COOKIE as $name => $value ) {
50  self::delete($name, $path);
51  }
52  }
53 }