예제 #1
0
 /**
  * Set a cookie value.
  *
  * @param string  $name    Name of cookie.
  * @param string  $value   Value.
  * @param integer $expires Unix epoch date for expiry.
  * @param string  $path    Cookie path.
  * @param string  $domain  Domain must be at least .domain.tld.
  * @param boolean $secure  To set if cookie must only be set over existing https connection.
  * @param boolean $signed  Override system setting to use signatures.
  *
  * @return boolean
  */
 public static function setCookie($name, $value = '', $expires = null, $path = null, $domain = null, $secure = null, $signed = true)
 {
     if (!$name) {
         return z_exit(__f("Error! In 'setCookie', you must specify at least the cookie name '%s'.", DataUtil::formatForDisplay($name)));
     }
     if (!is_string($value)) {
         return z_exit('setCookie: ' . DataUtil::formatForDisplay($value) . ' must be a string');
     }
     if (System::getVar('signcookies') && !$signed == false) {
         // sign the cookie
         $value = SecurityUtil::signData($value);
     }
     return setcookie($name, $value, $expires, $path, $domain, $secure);
 }