Skip to content
Permalink
Browse files
Add support for SameSite cookie setting (#203)
  • Loading branch information
rnewson authored and etrepum committed Sep 22, 2018
1 parent b095122 commit c06e08ee29e215cc7f3e5f940fabf5f5834a7096
Showing 1 changed file with 12 additions and 1 deletion.
@@ -52,6 +52,7 @@ cookie(Key, Value) ->
%% where Option = {max_age, int_seconds()} | {local_time, {date(), time()}}
%% | {domain, string()} | {path, string()}
%% | {secure, true | false} | {http_only, true | false}
%% | {same_site, lax | strict}
%%
%% @doc Generate a Set-Cookie header field tuple.
cookie(Key, Value, Options) ->
@@ -109,7 +110,17 @@ cookie(Key, Value, Options) ->
_ ->
""
end,
CookieParts = [Cookie, ExpiresPart, SecurePart, DomainPart, PathPart, HttpOnlyPart],
SameSitePart =
case proplists:get_value(same_site, Options) of
undefined ->
"";
lax ->
"; SameSite=Lax";
strict ->
"; SameSite=Strict"
end,
CookieParts = [Cookie, ExpiresPart, SecurePart, DomainPart, PathPart,
HttpOnlyPart, SameSitePart],
{"Set-Cookie", lists:flatten(CookieParts)}.


0 comments on commit c06e08e

Please sign in to comment.