Permalink
Browse files

Merge pull request #7495 from steveklabnik/issue_7478

Properly reset the session on reset_session
  • Loading branch information...
2 parents a667499 + 8bfcb0d commit abd47c15b870ea3cdbe610a02df03e9425870417 @tenderlove tenderlove committed Sep 2, 2012
@@ -227,8 +227,11 @@ def body_stream #:nodoc:
# TODO This should be broken apart into AD::Request::Session and probably
# be included by the session middleware.
def reset_session
- session.destroy if session && session.respond_to?(:destroy)
- self.session = {}
+ if session && session.respond_to?(:destroy)
+ session.destroy
+ else
+ self.session = {}
+ end
@env['action_dispatch.request.flash_hash'] = nil
end
@@ -44,6 +44,14 @@ class CookieStore < Rack::Session::Cookie
include StaleSessionCheck
include SessionObject
+ # Override rack's method
+ def destroy_session(env, session_id, options)
+ new_sid = super
+ # Reset hash and Assign the new session id
+ env["action_dispatch.request.unsigned_session_cookie"] = new_sid ? { "session_id" => new_sid } : {}
+ new_sid
+ end
+
private
def unpacked_cookie_data(env)
@@ -70,9 +70,12 @@ def options
def destroy
clear
options = self.options || {}
- @by.send(:destroy_session, @env, options[:id], options)
- options[:id] = nil
+ new_sid = @by.send(:destroy_session, @env, options[:id], options)
+ options[:id] = new_sid # Reset session id with a new value or nil
+
+ # Load the new sid to be written with the response
@loaded = false
+ load_for_write!
end
def [](key)

0 comments on commit abd47c1

Please sign in to comment.