예제 #1
0
파일: CookieTest.php 프로젝트: wagnert/http
 /**
  * Test instantiation of cookie object class
  */
 public function testHttpCookieInstantiationOfCookieObject()
 {
     $hash = md5(time());
     $dateTimeNow = new \DateTime();
     // init parser
     $cookie = new HttpCookie('testCookieName001', $hash, $dateTimeNow, null, 'testdomain.local', '/', false, true);
     // assert stuff
     $this->assertSame($cookie->getName(), 'testCookieName001');
     $this->assertSame($cookie->getValue(), $hash);
     $this->assertSame($cookie->getExpires(), $dateTimeNow->getTimestamp());
     $this->assertSame($cookie->getMaximumAge(), null);
     $this->assertSame($cookie->getDomain(), 'testdomain.local');
     $this->assertSame($cookie->getPath(), '/');
     $this->assertSame($cookie->isSecure(), false);
     $this->assertSame($cookie->isHttpOnly(), true);
 }
예제 #2
0
 /**
  * Set a cookie
  *
  * @param HttpCookie $aCookie
  *            The cookie to set
  *            
  * @return boolean
  */
 public function setCookie(HttpCookie $aCookie)
 {
     assert('$aCookie->getPath() !== null && $aCookie->getPath() !== ""');
     $result = setcookie($aCookie->getName(), self::encode($aCookie->getValue()), $aCookie->getExpire(), $aCookie->getPath(), $aCookie->getDomain(), $aCookie->getSecure(), $aCookie->getHttponly());
     if ($result === true) {
         $this->storedCookies[$aCookie->getName()] = $aCookie;
     }
     return $result;
 }