diff options
author | James Tucker <jftucker@gmail.com> | 2014-08-03 14:19:19 -0300 |
---|---|---|
committer | James Tucker <jftucker@gmail.com> | 2014-08-03 14:19:19 -0300 |
commit | d8e34e9dc9b78ca5fdb2271ef65cac8fd1c4496d (patch) | |
tree | 1054b8f7760183adf0406b31e44114707fe15436 | |
parent | 33075a489b85d43fc0be55d3503cc236f349e2f8 (diff) | |
parent | 75c68e6da577f1f976af7979e47d0c5c915f3a6c (diff) | |
download | rack-d8e34e9dc9b78ca5fdb2271ef65cac8fd1c4496d.tar.gz |
Merge pull request #697 from MichalBryxi/max_age
max-age settings forces Set-Cookie parameter
-rw-r--r-- | lib/rack/session/abstract/id.rb | 3 | ||||
-rw-r--r-- | lib/rack/utils.rb | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/rack/session/abstract/id.rb b/lib/rack/session/abstract/id.rb index e9edeb7f..62bdb04b 100644 --- a/lib/rack/session/abstract/id.rb +++ b/lib/rack/session/abstract/id.rb @@ -310,7 +310,7 @@ module Rack end def force_options?(options) - options.values_at(:renew, :drop, :defer, :expire_after).any? + options.values_at(:max_age, :renew, :drop, :defer, :expire_after).any? end def security_matches?(env, options) @@ -347,6 +347,7 @@ module Rack cookie = Hash.new cookie[:value] = data cookie[:expires] = Time.now + options[:expire_after] if options[:expire_after] + cookie[:expires] = Time.now + options[:max_age] if options[:max_age] set_cookie(env, headers, cookie.merge!(options)) end diff --git a/lib/rack/utils.rb b/lib/rack/utils.rb index 69a96eb9..42b2f5a0 100644 --- a/lib/rack/utils.rb +++ b/lib/rack/utils.rb @@ -267,9 +267,9 @@ module Rack def set_cookie_header!(header, key, value) case value when Hash - domain = "; domain=" + value[:domain] if value[:domain] - path = "; path=" + value[:path] if value[:path] - max_age = "; max-age=" + value[:max_age] if value[:max_age] + domain = "; domain=" + value[:domain] if value[:domain] + path = "; path=" + value[:path] if value[:path] + max_age = "; max-age=" + value[:max_age].to_s if value[:max_age] # There is an RFC mess in the area of date formatting for Cookies. Not # only are there contradicting RFCs and examples within RFC text, but # there are also numerous conflicting names of fields and partially |