title: Devise how to add signed in check in custom session controller?
body: <p>I am trying to use Devise's controller helper method signed_in? to check if a user already signed_in, if yes then I want to redirect to a specific page.</p>
  
  <p>I have tried this, but the signed_in? method always return true, how can I make this work?</p>
  
  <pre><code>class SessionsController &lt; Devise::SessionsController
    def new
      redirect_to root_url 
    end
  
    def create
      if signed_in?(resource_name)
        redirect_to where_-_want_to_url
      else  
        resource = warden.authenticate!(:scope =&gt; resource_name, :recall =&gt; "#{controller_path}#failure")
  
        return sign_in_and_redirect(resource_name, resource)
      end
    end
  
    def sign_in_and_redirect(resource_or_scope, resource=nil)
      scope = Devise::Mapping.find_scope!(resource_or_scope)
      resource ||= resource_or_scope
      sign_in(scope, resource) unless warden.user(scope) == resource
      return render :json =&gt; {:success =&gt; true, :redirect =&gt; stored_location_for(scope) || after_sign_in_path_for(resource)}
    end
  
    def failure      
      return render :json =&gt; { :success =&gt; false }
    end
  
  end
  </code></pre>