Skip to content

Commit 91d0be8

Browse files
committed
Cleanup cookies, ensure attributes are written in the spec order
...this should not matter, but the spec seems precise about ordering in some places
1 parent bb836db commit 91d0be8

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

app.lua

+5-7
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,16 @@ app.cookie_attributes = function (self)
8484
-- Cookies have a Max-Age of 35 days, because this is continually reset
8585
-- using the Snap!Cloud will continue to extend the user's cookie.
8686
-- Any update to `self.session.x` will extend the cookie's life.
87-
local attributes = "Path=/; HttpOnly; Domain="
88-
attributes = attributes .. ngx.var.host .. ';'
87+
local attributes = "Domain=" .. ngx.var.host .. "; Path=/;"
8988
if (config._name == 'development') then
90-
attributes = attributes .. " SameSite=Lax;"
89+
attributes = attributes .. " HttpOnly; SameSite=Lax; "
9190
else
92-
attributes = attributes .. " SameSite=None; Secure;"
91+
attributes = attributes .. " Secure; HttpOnly; SameSite=None;"
9392
end
9493
if self.session.persist_session == 'true' then
95-
local expires = 35 * 24 * 60 * 60
96-
attributes = "Max-Age=" .. expires .. "; " .. attributes
94+
local max_seconds = 35 * 24 * 60 * 60 -- 35 days, 24 hours, 60 minutes, 60 seconds
95+
attributes = "Max-Age=" .. max_seconds .. "; " .. attributes
9796
end
98-
debug_print('Cookie Attrs', attributes)
9997
return attributes
10098
end
10199

0 commit comments

Comments
 (0)