big update's coming
[mdref/mdref-http] / http / Cookie / __construct.md
1 # void http\Cookie::__construct([mixed $cookies = NULL[, int $flags = 0[, array $allowed_extras = NULL]]])
2
3 Create a new cookie list.
4
5 ## Params:
6
7 * Optional mixed $cookies = NULL
8 The string or list of cookies to parse or set.
9 * Optional int $flags = 0
10 Parse flags. See http\Cookie::PARSE_* constants.
11 * Optional array $allowed_extras = NULL
12 List of extra attribute names to recognize.
13
14 ## Throws:
15
16 * http\Exception\InvalidArgumentException
17 * http\Exception\RuntimeException
18
19 ## Example:
20
21 <?php
22 $cookie = new http\Cookie("c1=v1; c2=v2; extra=foo; ".
23 "expires=Thu, Nov 7 2013 10:00:00 GMT; path=/a/b/c",
24 0, ["extra"]);
25 var_dump([
26 "cookies" => $cookie->getCookies(),
27 "extras" => $cookie->getExtras(),
28 "expires" => $cookie->getExpires(),
29 "max-age" => $cookie->getMaxAge(),
30 "domain" => $cookie->getDomain(),
31 "path" => $cookie->getPath(),
32 "flags" => $cookie->getFlags(),
33 "string" => (string) $cookie
34 ]);
35 ?>
36
37 Yields:
38
39 array(8) {
40 ["cookies"]=>
41 array(2) {
42 ["c1"]=>
43 string(2) "v1"
44 ["c2"]=>
45 string(2) "v2"
46 }
47 ["extras"]=>
48 array(1) {
49 ["extra"]=>
50 string(3) "foo"
51 }
52 ["expires"]=>
53 int(1383818400)
54 ["max-age"]=>
55 int(-1)
56 ["domain"]=>
57 NULL
58 ["path"]=>
59 string(6) "/a/b/c"
60 ["flags"]=>
61 int(0)
62 ["string"]=>
63 string(77) "c1=v1; c2=v2; path=/a/b/c; expires=Thu, 07 Nov 2013 10:00:00 GMT; extra=foo; "
64 }