| 1 |
= cow_cookie:parse_cookie(3) |
| 2 |
|
| 3 |
== Name |
| 4 |
|
| 5 |
cow_cookie:parse_cookie - Parse a cookie header |
| 6 |
|
| 7 |
== Description |
| 8 |
|
| 9 |
[source,erlang] |
| 10 |
---- |
| 11 |
parse_cookie(Cookie :: binary()) |
| 12 |
-> parse_cookie(Cookie, #{}) |
| 13 |
parse_cookie(Cookie :: binary(), Opts) |
| 14 |
-> [{binary(), binary()}] |
| 15 |
|
| 16 |
Opts :: #{max_cookies => non_neg_integer()} |
| 17 |
---- |
| 18 |
|
| 19 |
Parse a cookie header. |
| 20 |
|
| 21 |
== Arguments |
| 22 |
|
| 23 |
Cookie:: |
| 24 |
|
| 25 |
The cookie header value. |
| 26 |
|
| 27 |
== Return value |
| 28 |
|
| 29 |
A list of cookie name/value pairs is returned on success. |
| 30 |
|
| 31 |
An exception is thrown in the event of a parse error. |
| 32 |
|
| 33 |
== Changelog |
| 34 |
|
| 35 |
* *2.19*: Function `parse_cookie/2` introduced with a |
| 36 |
`max_cookies` option. |
| 37 |
* *2.9*: Fixes to the parser may lead to potential incompatibilities. |
| 38 |
A cookie name starting with `$` is no longer ignored. |
| 39 |
A cookie without a `=` will be parsed as the value of |
| 40 |
the cookie named `<<>>` (empty name). |
| 41 |
* *1.0*: Function introduced. |
| 42 |
|
| 43 |
== Examples |
| 44 |
|
| 45 |
.Parse a cookie header |
| 46 |
[source,erlang] |
| 47 |
---- |
| 48 |
Cookies = cow_cookie:parse_cookie(CookieHd). |
| 49 |
---- |
| 50 |
|
| 51 |
== See also |
| 52 |
|
| 53 |
link:man:cow_cookie(3)[cow_cookie(3)], |
| 54 |
link:man:cow_cookie:parse_set_cookie(3)[cow_cookie:parse_set_cookie(3)], |
| 55 |
link:man:cow_cookie:cookie(3)[cow_cookie:cookie(3)], |
| 56 |
link:man:cow_cookie:setcookie(3)[cow_cookie:setcookie(3)] |