From 92b54aacc0de5446dd5497c39897b0bbff72e626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 13 Jun 2018 09:54:12 +0200 Subject: Rebuild using Asciideck --- .../manual/cowboy_req.set_resp_cookie/index.html | 189 +++++++-------------- 1 file changed, 63 insertions(+), 126 deletions(-) (limited to 'docs/en/cowboy/2.4/manual/cowboy_req.set_resp_cookie/index.html') diff --git a/docs/en/cowboy/2.4/manual/cowboy_req.set_resp_cookie/index.html b/docs/en/cowboy/2.4/manual/cowboy_req.set_resp_cookie/index.html index 157e9162..6844dc8e 100644 --- a/docs/en/cowboy/2.4/manual/cowboy_req.set_resp_cookie/index.html +++ b/docs/en/cowboy/2.4/manual/cowboy_req.set_resp_cookie/index.html @@ -62,167 +62,104 @@

cowboy_req:set_resp_cookie(3)

-

Name

-
-

cowboy_req:set_resp_cookie - Set a cookie

-
-
-
+

cowboy_req:set_resp_cookie - Set a cookie

Description

-
-
-
-
set_resp_cookie(Name, Value, Req :: cowboy_req:req())
-    -> set_resp_cookie(Name, Value, [], Req)
-
-set_resp_cookie(Name, Value, Req :: cowboy_req:req(), Opts)
-    -> Req
-
-Name  :: binary()                  %% case sensitive
-Value :: iodata()                  %% case sensitive
-Opts  :: cow_cookie:cookie_opts()
-

Set a cookie to be sent with the response.

-

Note that cookie names are case sensitive.

-
-
-
+
set_resp_cookie(Name, Value, Req :: cowboy_req:req())
+    -> set_resp_cookie(Name, Value, [], Req)
+
+set_resp_cookie(Name, Value, Req :: cowboy_req:req(), Opts)
+    -> Req
+
+Name  :: binary()                  %% case sensitive
+Value :: iodata()                  %% case sensitive
+Opts  :: cow_cookie:cookie_opts()
+
+

Set a cookie to be sent with the response.

+

Note that cookie names are case sensitive.

Arguments

-
-
-
-Name -
-
-

-Cookie name. -

+
Name
+

Cookie name.

-
-Value -
-
-

-Cookie value. -

+
Value
+

Cookie value.

-
-Req -
-
-

-The Req object. -

+
Req
+

The Req object.

-
-Opts -
-
-

-Cookie options. -

+
Opts
+

Cookie options.

-
-
- -
+

Return value

-
-

A new Req object is returned.

-

The returned Req object must be used from that point onward, -otherwise the cookie will not be sent in the response.

-
-
-
+

A new Req object is returned.

+

The returned Req object must be used from that point onward, otherwise the cookie will not be sent in the response.

Changelog

-
-
    -
  • -

    -2.0: set_resp_cookie/3 introduced as an alias to set_resp_cookie/4 with no options. -

    +
    • 2.0: set_resp_cookie/3 introduced as an alias to set_resp_cookie/4 with no options.
    • -
    • -

      -2.0: The first argument type is now binary() instead of iodata(). -

      +
    • 2.0: The first argument type is now binary() instead of iodata().
    • -
    • -

      -1.0: Function introduced. -

      +
    • 1.0: Function introduced.
    • -
-
-
-
+

Examples

-
-
-
Set a session cookie
-
-
SessionID = base64:encode(crypto:strong_rand_bytes(32)),
-Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, Req0).
-
-
Set a cookie with an expiration time
-
-
Req = cowboy_req:set_resp_cookie(<<"lang">>, <<"fr-FR">>,
-    Req0, #{max_age => 3600}).
-
-
Delete a cookie
-
-
Req = cowboy_req:set_resp_cookie(<<"sessionid">>, <<>>,
-    Req0, #{max_age => 0}).
-
-
Set a cookie for a specific domain and path
-
-
Req = cowboy_req:set_resp_cookie(<<"inaccount">>, <<"1">>,
-    Req0, #{domain => "my.example.org", path => "/account"}).
-
-
Restrict a cookie to HTTPS
-
-
SessionID = base64:encode(crypto:strong_rand_bytes(32)),
-Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID,
-    Req0, #{secure => true}).
-
-
Restrict a cookie to HTTP
-
-
SessionID = base64:encode(crypto:strong_rand_bytes(32)),
-Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID,
-    Req0, #{http_only => true}).
-
-
-
+
SessionID = base64:encode(crypto:strong_rand_bytes(32)),
+Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID,
+    Req0, #{http_only => true}).
+

See also

-
- -
- +

cowboy_req(3), cowboy_req:set_resp_header(3), cowboy_req:set_resp_headers(3), cowboy_req:reply(3), cowboy_req:stream_reply(3)

+ -- cgit v1.2.3