2015-08-03 02:49:12 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
2015-03-08 18:02:59 +01:00
|
|
|
|
|
|
|
class Cookie {
|
|
|
|
|
2017-11-07 00:18:16 +01:00
|
|
|
public static function get($key)
|
2015-03-08 18:02:59 +01:00
|
|
|
{
|
2017-11-07 00:18:16 +01:00
|
|
|
if (isset($_COOKIE[$key])) {
|
|
|
|
return $_COOKIE[$name];
|
2015-03-08 18:02:59 +01:00
|
|
|
}
|
2017-11-07 00:18:16 +01:00
|
|
|
return false;
|
2015-03-08 18:02:59 +01:00
|
|
|
}
|
|
|
|
|
2017-11-07 00:18:16 +01:00
|
|
|
public static function set($key, $value, $daysToExpire=30)
|
2015-03-08 18:02:59 +01:00
|
|
|
{
|
2017-11-07 00:18:16 +01:00
|
|
|
// The time the cookie expires.
|
|
|
|
// This is a Unix timestamp so is in number of seconds since the epoch.
|
|
|
|
// In other words, you'll most likely set this with the time() function plus the number of seconds before you want it to expire.
|
|
|
|
// Or you might use mktime(). time()+60*60*24*30 will set the cookie to expire in 30 days.
|
|
|
|
// If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).
|
|
|
|
$expire = time()+60*60*24*$daysToExpire;
|
|
|
|
setcookie($key, $value, $expire);
|
2015-03-08 18:02:59 +01:00
|
|
|
}
|
|
|
|
|
2017-11-07 00:18:16 +01:00
|
|
|
public static function isset($key)
|
2015-03-08 18:02:59 +01:00
|
|
|
{
|
2017-11-07 00:18:16 +01:00
|
|
|
return isset($_COOKIE[$key]);
|
2015-03-08 18:02:59 +01:00
|
|
|
}
|
|
|
|
|
2017-11-07 00:18:16 +01:00
|
|
|
}
|