示例#1
0
 public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAndSecureAndHttpOnly()
 {
     $name = 'foo';
     $value = 'bar';
     $domain = 'foo.com';
     $path = '/foo';
     $expires = strtotime('2 days');
     $expiresFormat = gmdate('D, d-M-Y H:i:s e', $expires);
     $secure = true;
     $httpOnly = true;
     $header = array();
     Slim_Http_Util::setCookieHeader($header, $name, array('value' => $value, 'domain' => $domain, 'path' => '/foo', 'expires' => $expires, 'secure' => $secure, 'httponly' => $httpOnly));
     $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat . '; secure; HttpOnly', $header['Set-Cookie']);
 }
示例#2
0
 /**
  * Set cookie
  *
  * Instead of using PHP's `setcookie()` function, Slim manually constructs the HTTP `Set-Cookie`
  * header on its own and delegates this responsibility to the `Slim_Http_Util` class. This
  * response's header is passed by reference to the utility class and is directly modified. By not
  * relying on PHP's native implementation, Slim allows middleware the opportunity to massage or
  * analyze the raw header before the response is ultimately delivered to the HTTP client.
  *
  * @param   string          $name   The name of the cookie
  * @param   string|array    $value  If string, the value of cookie; if array, properties for
  *                                  cookie including: value, expire, path, domain, secure, httponly
  */
 public function setCookie($name, $value)
 {
     Slim_Http_Util::setCookieHeader($this->header, $name, $value);
 }