expire() public method

On executing this method, the expiry time of this cookie is set to a point in time in the past triggers the removal of the cookie in the user agent.
public expire ( ) : void
return void
 /**
  * Data provider with cookies and their expected string representation.
  *
  * @return array
  */
 public function cookiesAndTheirStringRepresentations()
 {
     $expiredCookie = new Cookie('foo', 'bar');
     $expiredCookie->expire();
     return [[new Cookie('foo', 'bar'), 'foo=bar; Path=/; HttpOnly'], [new Cookie('MyFoo25', 'bar'), 'MyFoo25=bar; Path=/; HttpOnly'], [new Cookie('MyFoo25', true), 'MyFoo25=1; Path=/; HttpOnly'], [new Cookie('MyFoo25', false), 'MyFoo25=0; Path=/; HttpOnly'], [new Cookie('foo', 'bar', 0), 'foo=bar; Path=/; HttpOnly'], [new Cookie('MyFoo25'), 'MyFoo25=; Path=/; HttpOnly'], [new Cookie('foo', 'It\'s raining cats and dogs.'), 'foo=It%27s+raining+cats+and+dogs.; Path=/; HttpOnly'], [new Cookie('foo', 'Some characters, like "double quotes" must be escaped.'), 'foo=Some+characters%2C+like+%22double+quotes%22+must+be+escaped.; Path=/; HttpOnly'], [new Cookie('foo', 'bar', 1345108546), 'foo=bar; Expires=Thu, 16-Aug-2012 09:15:46 GMT; Path=/; HttpOnly'], [new Cookie('foo', 'bar', \DateTime::createFromFormat('U', 1345108546)), 'foo=bar; Expires=Thu, 16-Aug-2012 09:15:46 GMT; Path=/; HttpOnly'], [new Cookie('foo', 'bar', 0, null, 'flow.neos.io'), 'foo=bar; Domain=flow.neos.io; Path=/; HttpOnly'], [new Cookie('foo', 'bar', 0, null, 'flow.neos.io', '/about'), 'foo=bar; Domain=flow.neos.io; Path=/about; HttpOnly'], [new Cookie('foo', 'bar', 0, null, 'neos.io', '/', true), 'foo=bar; Domain=neos.io; Path=/; Secure; HttpOnly'], [new Cookie('foo', 'bar', 0, null, 'neos.io', '/', true, false), 'foo=bar; Domain=neos.io; Path=/; Secure'], [new Cookie('foo', 'bar', 0, 3600), 'foo=bar; Max-Age=3600; Path=/; HttpOnly'], [$expiredCookie, 'foo=bar; Expires=Thu, 27-May-1976 12:00:00 GMT; Path=/; HttpOnly']];
 }
Ejemplo n.º 2
0
 /**
  * Explicitly destroys all session data
  *
  * @param string $reason A reason for destroying the session – used by the LoggingAspect
  * @return void
  * @throws Exception\SessionNotStartedException
  * @api
  */
 public function destroy($reason = null)
 {
     if ($this->started !== true) {
         throw new Exception\SessionNotStartedException('Tried to destroy a session which has not been started yet.', 1351162668);
     }
     if ($this->remote !== true) {
         if (!$this->response->hasCookie($this->sessionCookieName)) {
             $this->response->setCookie($this->sessionCookie);
         }
         $this->sessionCookie->expire();
     }
     $this->removeSessionMetaDataCacheEntry($this->sessionIdentifier);
     $this->storageCache->flushByTag($this->storageIdentifier);
     $this->started = false;
     $this->sessionIdentifier = null;
     $this->storageIdentifier = null;
     $this->tags = [];
     $this->request = null;
 }