cookies() 공개 메소드

This function's parameters are designed to be analogous to setcookie(). Function parameters expire, path, domain, secure, and httponly may be passed in as an associative array alongside value inside $value. NOTE: Cookies values are expected to be scalar. This function will not serialize cookie values. If you wish to store a non-scalar value, you must serialize the data first. NOTE: Cookie values are stored as an associative array containing at minimum a value key. Cookies which have been set multiple times do not overwrite each other. Rather they are stored as an array of associative arrays.
public cookies ( string $key = null, string $value = null ) : mixed
$key string
$value string
리턴 mixed
예제 #1
0
 public function testSetCookiesMultipleValues()
 {
     $response = new Response();
     $response->cookies(array('foo' => 'bar', 'bin' => 'baz'));
     $response->cookies('foo', array('value' => 'bin', 'path' => '/foo'));
     $expected = array('foo' => array(array('value' => 'bar'), array('value' => 'bin', 'path' => '/foo')), 'bin' => array('value' => 'baz'));
     $result = $response->cookies;
     $this->assertEqual($expected, $result);
     $response = new Response();
     $response->cookies(array('foo' => array('bar', array('value' => 'bin', 'path' => '/foo')), 'bin' => 'baz'));
     $result = $response->cookies;
     $this->assertEqual($expected, $result);
 }