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.
Matthew M. (Guest)
on 2007-03-28 09: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 M.
Philip H. (Guest)
on 2007-03-28 19: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.