I recently upgraded my Rails app from version 7.0.4.3 to version 7.1.3.4 and cookies.delete
stopped working.
I’m setting a cookie in JavaScript with:
document.cookie = `last_guess=value; path=/`;
then process and remove the cookie with an action (before_action
) inside ApplicationController
with:
cookie_value = cookies.delete(:last_guess)
This is working fine with version 7.0.4.3. However it stopped working with version 7.1.3.4.
If I print out the cookies after delete, the cookie is part of @delete_cookies
:
#<ActionDispatch::Cookies::CookieJar:0x000000011432d0b0 @set_cookies={}, @delete_cookies={"last_guess"=>{:domain=>"localhost", :path=>"/", :same_site=>:lax}},...
but the cookie is still present in the browser. I tried deleting the cookie with options like domain: "localhost", path: "/", same_site: :lax
, but it didn’t help.
Am I missing something for this to work correctly?