This project is archived and is in readonly mode.
Rails always resend the same cookie with active_record sessions
-
Prem Sichanugrist (sikachu)
- State changed from new to verified
- Tag set to 2.3.6, 3.0, actionpack, sessions
- Assigned user set to Prem Sichanugrist (sikachu)
+1 on both 3.0 and 2.3.5. Will provide a patch soon.
Also, I found this behavior in every
session_store. Global patching will be fine -
donncha
Possibly??
module ActionController #:nodoc: module Cookies protected # Returns the cookie container, which operates as described above. def cookies - @cookies ||= CookieJar.new(self) + CookieJar.new(self) end end end -
Rizwan Reza
- Tag changed from 2.3.6, 3.0, actionpack, sessions to 2.3.6, 3.0, actionpack, bugmash, sessions
- State changed from verified to open
-
Rohit Arondekar
Any updates here? Can somebody please try and verify if this is still an issue on master.
-
Prem Sichanugrist (sikachu)
Hi,
I can verify that it still apply to current
master. I was working on it, but didn't finish it.Will come back and provide patch for it soon.
-
José Valim
What always resending the cookie is an issue?
-
José Valim
Sorry! For ActiveRecord store, since the cookie only contains the session_id, it does not make sense to send the same cookie every time. Yes, this should be fixed!
-
Prem Sichanugrist (sikachu)
Ok, so I've patched the abstract_store to check that the session_id value has been changed or not. If not, then it won't call the
[]=of cookie jar, which was resulted in sending the cookie back to user again.Noted that I also checked that the
expiredis not set. If it does, it will always resend thesession_idcookie regardless of whether it's already set or not, to extend the expire time.I've attach the patch that cleanly apply on
master. Patch for2-3-stablehopefully will come soon. -
José Valim
- Milestone cleared.
- Assigned user changed from Prem Sichanugrist (sikachu) to José Valim
-
Prem Sichanugrist (sikachu)
- Tag changed from 2.3.6, 3.0, actionpack, bugmash, sessions to 2.3.x, 3.0, actionpack, bugmash, sessions
It isn't quite hard to backport, so here it is
-
Repository
- State changed from open to resolved
(from [617e94658ddc3f71c42fc4f8c2346f87ff106bbe]) Make sure that Rails doesn't resent session_id cookie over and over again if it's already there [#2485 Rails always resend the same cookie with active_record sessions state:resolved]
This apply to only Active Record store and Memcached store, as they both store only the session_id, which will be unchanged, in the cookie.
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/617e94658ddc3f71c42fc4f8c2346f... -
Repository
(from [f8f365346ec55ef388eaa43e30bd7629c375d274]) Make sure that Rails doesn't resent session_id cookie over and over again if it's already there [#2485 Rails always resend the same cookie with active_record sessions state:resolved]
This apply to only Active Record store and Memcached store, as they both store only the session_id, which will be unchanged, in the cookie.
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/f8f365346ec55ef388eaa43e30bd76... -
jsman
- Importance changed from to
This commit broke the ActiveRecord session store in 2.3.9. If there is currently no cookie with a session id present at the client side, no new cookie is ever created and every request will generate a new session id (but no cookie).
