diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-05-21 13:44:12 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-05-21 13:44:12 -0400 |
commit | d68d3a3357c46933b604c03a8f8d6a60fa952106 (patch) | |
tree | d39c4c6543a8512faaef99e0c10c95ef13d947e0 /src | |
parent | 3eb07fcdf2a227009faa11eddf96fe63952533c6 (diff) | |
download | guff-d68d3a3357c46933b604c03a8f8d6a60fa952106.tar.bz2 guff-d68d3a3357c46933b604c03a8f8d6a60fa952106.zip |
DRY session cookie name
Diffstat (limited to 'src')
-rw-r--r-- | src/guff.cr | 12 |
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, |