big update's coming
[mdref/mdref-http] / http / Client / Response / getCookies.md
1 # mixed http\Client\Response::getCookies([int $flags = 0[, array $allowed_extras = NULL]])
2
3 Extract response cookies.
4 Parses any "Set-Cookie" response headers into an http\Cookie list. See http\Cookie::__construct().
5
6 ## Params:
7
8 * Optional int $flags = 0
9 Cookie parser flags.
10 * Optional array $allowed_extras = NULL
11 List of keys treated as extras.
12
13 ## Returns:
14
15 * array, list of http\Cookie instances.
16
17 ## Example:
18
19 <?php
20 $response = (new http\Client)
21 ->enqueue(new http\Client\Request("GET", "http://php.net/"))
22 ->send()
23 ->getResponse();
24
25 foreach ($response->getCookies() as $cookie) {
26 /* @var $cookie http\Cookie */
27 foreach ($cookie->getCookies() as $name => $value) {
28 printf("Got a cookie named '%s' with value '%s'\n\tdomain=%s\n\t path=%s\n",
29 $name, $value, $cookie->getDomain(), $cookie->getPath());
30 }
31 }
32 ?>
33
34 Yields:
35
36 Got a cookie named 'COUNTRY' with value 'USA,72.52.91.14'
37 domain=.php.net
38 path=/