cow_cookie.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. = cow_cookie(3)
  2. == Name
  3. cow_cookie - Cookies
  4. == Description
  5. The module `cow_cookie` provides functions for parsing
  6. and manipulating cookie headers.
  7. == Exports
  8. * link:man:cow_cookie:parse_cookie(3)[cow_cookie:parse_cookie(3)] - Parse a cookie header
  9. * link:man:cow_cookie:parse_set_cookie(3)[cow_cookie:parse_set_cookie(3)] - Parse a set-cookie header
  10. * link:man:cow_cookie:cookie(3)[cow_cookie:cookie(3)] - Generate a cookie header
  11. * link:man:cow_cookie:setcookie(3)[cow_cookie:setcookie(3)] - Generate a set-cookie header
  12. == Types
  13. === cookie_attrs()
  14. [source,erlang]
  15. ----
  16. cookie_attrs() :: #{
  17. expires => calendar:datetime(),
  18. max_age => calendar:datetime(),
  19. domain => binary(),
  20. path => binary(),
  21. secure => true,
  22. http_only => true,
  23. same_site => strict | lax | none
  24. }
  25. ----
  26. Cookie attributes parsed from the set-cookie header.
  27. The attributes must be passed as-is to a cookie store
  28. engine for processing, along with the cookie name and value.
  29. More information about the attributes can be found in
  30. https://tools.ietf.org/html/rfc6265[RFC 6265].
  31. === cookie_opts()
  32. [source,erlang]
  33. ----
  34. cookie_opts() :: #{
  35. domain => binary(),
  36. http_only => boolean(),
  37. max_age => non_neg_integer(),
  38. path => binary(),
  39. same_site => strict | lax | none,
  40. secure => boolean()
  41. }
  42. ----
  43. Options for the set-cookie header. They are added to the
  44. header as attributes. More information about the options
  45. can be found in https://tools.ietf.org/html/rfc6265[RFC 6265].
  46. The following options are defined:
  47. domain::
  48. Hosts to which the cookie will be sent. By default it will
  49. only be sent to the origin server.
  50. http_only::
  51. Whether the cookie should be restricted to HTTP requests, or
  52. it should also be exposed to other APIs, for example Javascript.
  53. By default there are no restrictions.
  54. max_age::
  55. Maximum lifetime of the cookie, in seconds. By default the
  56. cookie is kept for the duration of the session.
  57. path::
  58. Path to which the cookie will be sent. By default it will
  59. be sent to the current "directory" of the effective request URI.
  60. same_site::
  61. Whether the cookie should be sent along with cross-site
  62. requests. This attribute is currently non-standard but is in
  63. the process of being standardized. Please refer to the
  64. https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7[RFC 6265 (bis) draft]
  65. for details.
  66. +
  67. The default value for this attribute may vary depending on
  68. user agent and configuration. Browsers are known to be more
  69. strict over TCP compared to TLS.
  70. secure::
  71. Whether the cookie should be sent only on secure channels
  72. (for example TLS). Note that this does not guarantee the
  73. integrity of the cookie, only its confidentiality during
  74. transfer. By default there are no restrictions.
  75. == Changelog
  76. * *2.10*: The `same_site` attribute and option may now be
  77. set to `none`.
  78. * *2.9*: The `cookie_attrs` type was added.
  79. * *1.0*: Module introduced.
  80. == See also
  81. link:man:cowlib(7)[cowlib(7)],
  82. https://tools.ietf.org/html/rfc6265[RFC 6265]