impossible to access cookie in custom failure app #1682

JohnMerlino1 opened this Issue Feb 27, 2012 · 4 comments


None yet

3 participants


I'm trying to access a cookie in custom failure app, because when the user enters the wrong password, I want to delete a cookie called tracker_for_external_clients. However, when you add a class in lib directory, there's no way to access the cookie hash. So I tried adding a class method to CustomFailureApp:

class CustomFailureApp < Devise::FailureApp
   class << self
     attr_accessor :cookie

and tried adding this to application controller:

def initialize
   CustomFailureApp.cookie cookies           

So that I could then modify the cookie in CustomFailureApp:

def respond    
    unless request.format.to_sym == :html
    flash[:alert] = i18n_message

    if request.subdomain == 'abc' && i18n_message.includes?('Invalid login or password')
      CustomFailureApp.cookie.delete :tracker_for_external_clients           
      uri = URI('')          
      params = { 'message' => i18n_message }
      uri.query = URI.encode_www_form(params)

      res = Net::HTTP.get_response(uri)

      if res.is_a?(Net::HTTPSuccess)            "The response is #{res.body}" 
      else "Something went wrong"

       redirect_to redirect_url


But I get this error:
undefined method `cookie_jar' for nil:NilClass

I need to be able to delete the cookie after devise has determined the user has entered the wrong password, so that i could kill the proxy i am using between two servers.

thanks for response


Please read:

And please format the code in the report properly.
If you don't care enough to format it yourself, you cannot expect a bigger effort from us on helping you. Thanks.

@josevalim josevalim closed this Feb 27, 2012

I formatted code, and I know for fact that I will not get an answer to this on google groups. I already have asked 4 devise questions in past on google groups to which no response. So I am not sure why this issue is closed. It's clear that there is a defined issue here: "How do you have control (in this case deleting a cookie) after devise has determined that a user has entered the wrong password in the latest version of devise." Thanks for response and consideration in reopening the issue. And if you would like to reply to the question on google groups its here: thanks for response


The thing is, this is a user issue, not a Devise issue. In any case, you should be able to access the cookies as request.cookie_jar in the failure app.


i worked around this problem with

def cookies

inside the custom failure app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment