コード例 #1
0
ファイル: Response.php プロジェクト: aurora-framework/http
 public function deleteCookie(CookieInterface $Cookie)
 {
     $Cookie->setValue('');
     $Cookie->setMaxAge(-1);
     $this->cookies[$Cookie->getName()] = $Cookie;
     return $this;
 }
コード例 #2
0
ファイル: CookieHandler.php プロジェクト: tekkla/core-http
 /**
  * Adds a cookie to the cookies stack
  *
  * The cookie will be stored by using it's name as index for the cookies stack, so it's possible that an already
  * present cookie with the same name gets replaced by the one you are adding.
  *
  * @param CookieInterface $cookie
  *            The cookie to add
  * @param bool $overwrite
  *            Optional flag to control overwriting of an cookie stored with the same name.
  *            Instead of replacing an existing cookie a CookieException will be thrown.
  *
  * @throws CookieException
  */
 public function addCookie(CookieInterface $cookie, bool $overwrite = true)
 {
     $cookie_name = $cookie->getName();
     if ($overwrite == false && array_key_exists($cookie_name, $this->cookies)) {
         throw new CookieException(sprintf('A cookie with name "%s" already exists.', $cookie_name));
     }
     $this->cookies[$cookie_name] = $cookie;
 }
コード例 #3
0
ファイル: UnsetCookie.php プロジェクト: tomkyle/cookies
 public function __construct(CookieInterface $cookie, &$target_array = null)
 {
     $name = $cookie->getName();
     // Empty cookie itself
     $cookie->setValue(null);
     // Un-populate current superglobals
     if (is_array($target_array)) {
         unset($target_array[$name]);
     } else {
         unset($_COOKIE[$name]);
     }
     // Unset over HTTP
     setcookie($name, null, -1);
 }
コード例 #4
0
ファイル: SendCookie.php プロジェクト: tomkyle/cookies
 public function __construct(CookieInterface $cookie, &$target_array = null)
 {
     $name = $cookie->getName();
     $value = $cookie->getValue();
     $expire = $cookie->getExpiration();
     $expire = $expire ? $expire->getTimestamp() : null;
     // Populate current superglobals (or overriden one)
     if (is_array($target_array)) {
         $target_array[$name] = $value;
     } else {
         $_COOKIE[$name] = $value;
     }
     // Unset over HTTP
     setcookie($name, $value, $expire);
 }