0

On Ruby on Rails 6; I'm trying to remove the session cookie. The cookie was needed for a short while to contain a flash message though a redirect and once the flash message is done, I want to remove the cookie completely. No resets, I want the cookie gone.

I've tried

  session.clear
  session.destroy
  cookies.delete cookie_name.to_sym

Is there a way to delete the session cookie?

Daniel
  • 7,006
  • 7
  • 43
  • 49
  • Which `config.session_store` are you using? – Jared Beck Sep 22 '21 at 21:26
  • We store to Redis – Daniel Sep 22 '21 at 21:33
  • So you store your session _data_ in Redis, but the session _id_ is still stored as a cookie, right? You have to store the _id_ somewhere. Are you going to put it in the URL instead, or in an HTTP header? – Jared Beck Sep 27 '21 at 20:25
  • There are some interesting ideas here: https://stackoverflow.com/questions/47055984/i-would-like-to-know-how-to-disable-cookies-in-rails-5-1 – Jared Beck Sep 27 '21 at 20:33
  • Was the cookie was originally set with a `domain` option? If so, you may need to provide that domain as an option again when calling`cookies.delete`. (According to the docs at https://api.rubyonrails.org/classes/ActionDispatch/Cookies.html ) – obiruby Sep 28 '21 at 18:59
  • @JaredBeck The session is empty the session id would be stored in the cookie, except I'm trying to remove the session cookie so that it does not come back . in regards to 2nd comment, I still need cookies here and there. – Daniel Sep 28 '21 at 21:44
  • @obiruby I added domain: (my domain). Good catch, but it didn't work – Daniel Sep 28 '21 at 21:44

0 Answers0