2

I am trying to delete the session cookie and havent had any success. Ive tried reset_session, cookies.delete(:id), cookies.clear and nothing has worked. I feel like I'm missing something, can anyone help?
Rails 3.2.1

SteveO7
  • 2,430
  • 3
  • 32
  • 40

1 Answers1

4

I believe this will give you the answer:

StackoverFlow Similar question

session[:current_user_id] = nil

This works fine in Rails 3.2.1

reset_session

Shreds everything...

Community
  • 1
  • 1
Pedro Ferreira
  • 629
  • 3
  • 8
  • I've tried both, but the session cookie is still on the browser. It almost feels like I'm dealing with a bug. – SteveO7 Mar 22 '12 at 19:33
  • 1
    Digging a little deeper,; if I debug and watch the cookie and session objects, they do get set to nil, but the cookie still exists. Am I expecting to much to expect to see the cookie vanish from the browser? – SteveO7 Mar 22 '12 at 19:47
  • An empty cookie will exist for any website you visit. If its at nil there wont be any details there. If you want to physically delete the cookie file, it will be heavy due to multiple browsers having diferent ways of doing it. – Pedro Ferreira Mar 23 '12 at 10:02
  • The session objects at nil is not what you want then? You want to remove the cookie? – Pedro Ferreira Mar 23 '12 at 10:03
  • My expectation was that cookie.delete would remove the cookie from the browser, not just set it to nil. I really dont want any browser specific code so I think I just need to change my expectation. THanks for your help! – SteveO7 Mar 23 '12 at 12:32
  • That expectation will be met in some browsers. But for example IE only erases cookies even if at nil on exit. – Pedro Ferreira Mar 23 '12 at 12:41