Forum: Ruby on Rails want to delete all cookies

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
397032cb9a9aa71fef9b02a3f0dfded3?d=identicon&s=25 Matthew Margolis (Guest)
on 2007-03-28 07:30
(Received via mailing list)
I am looking to delete all cookies that I set when a user logs out of
my application.

   def logout
     for cook in cookies
       cookies.delete cook[0]
     end
     redirect_to '/'
   end

does not seem to be doing the trick. Even though it looks right in my
log file the cookies don't actually expire.  Any ideas?

Thank you,
Matt Margolis
2f9a03aa0fcfe945229cb6126eda2cb2?d=identicon&s=25 Philip Hallstrom (Guest)
on 2007-03-28 17:01
(Received via mailing list)
> does not seem to be doing the trick. Even though it looks right in my
> log file the cookies don't actually expire.  Any ideas?

This works for me...

cookies.to_hash.each_pair do |k, v|
   cookies[k.to_sym] = { :value => '',
                         :path => '/',
                         :domain => '.domain.com',
                         :expire => 1.day.ago }
end

redirect_to '/'
This topic is locked and can not be replied to.