Deleting Cookies from a Controller

For example, your cookie look like this

cookies[:foo] = {:value => 'bar', :domain => '.text.com'}

As you tried this one => cookies.delete :foo

The logs will say => Cookie set: foo=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT

Notice that the domain is missing. Tried this way

cookies.delete :foo, :domain =>
‘.text.com’

Function = >

# Removes the cookie on the client machine by setting the value to an empty string
# and setting its expiration date into the past.  Like []=, you can pass in an options
# hash to delete cookies with extra data such as a +path+.
def delete(name, options = {})
  options.stringify_keys!
  set_cookie(options.merge("name" => name.to_s, "value" => "", "expires" => Time.at(0)))
end

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)