cow_cookie:setcookie(3)

NAME

cow_cookie:setcookie - Generate a set-cookie header

DESCRIPTION
    setcookie(Name  :: iodata(),
              Value :: iodata(),
              Opts  :: cow_cookie:cookie_opts())
        -> iolist()

Generate a set-cookie header.

Note that this function expects the Name, Value arguments as well as the domain or path options to be safe, meaning they do not contain invalid characters according to RFC6265 section 4.1.1.

ARGUMENTS

Name
    Cookie name.

Value
    Cookie value.

Opts
    Options added to the set-cookie header as attributes.

RETURN VALUE

An iolist with the generated set-cookie header value.

CHANGELOG
    • 2.12: The Version attribute is no longer generated.
    • 1.0: Function introduced.

EXAMPLES

Generate a set-cookie header
    SetCookie = cow_cookie:setcookie(<<"sessionid">>, ID, #{
        http_only => true,
        secure    => true
    }).

SEE ALSO

cow_cookie(3), cow_cookie:parse_cookie(3), cow_cookie:parse_set_cookie(3), cow_cookie:cookie(3)