aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/guff.cr12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/guff.cr b/src/guff.cr
index f25e1c3..503fded 100644
--- a/src/guff.cr
+++ b/src/guff.cr
@@ -303,6 +303,10 @@ module Guff
class Session < Hash(String, String)
getter :session_id
+ # session cookie name
+ # FIXME: does this belong here
+ COOKIE = "guff_session"
+
def initialize(@context : Context)
super()
@session_id = nil
@@ -474,9 +478,9 @@ module Guff
# clear session
@context.session.clear
- if context.request.cookies.has_key?("guff_sid")
+ if cookie = context.request.cookies[Guff::Session::COOKIE]?
# load session
- @context.session.load(context.request.cookies["guff_sid"].value)
+ @context.session.load(cookie.value)
end
call_next(context)
@@ -606,7 +610,7 @@ module Guff
# add cookie
context.response.cookies << HTTP::Cookie.new(
- name: "guff_sid",
+ name: Guff::Session::COOKIE,
value: session_id as String,
http_only: true,
@@ -698,7 +702,7 @@ module Guff
# clear cookie
context.response.cookies << HTTP::Cookie.new(
- name: "guff_sid",
+ name: Guff::Session::COOKIE,
value: "",
expires: Time.epoch(0),
http_only: true,