redirecting if cookie doesn't exist

Hi all,

I cannot get this to work at all .. it never does the redirect.

I have two authentication cookies set ... Rails reads thier values fine if
they exist

If they don't exist, I want to redirect the user to the login page -- which
is not a rails controller/model ....(single sign on location)

I figured I'd add the code to the application_helper ... so that I could
reference it in all my views.

module ApplicationHelper

  def ifLoggedIn()
        if (!useridcookie)
          redirect_to "http://loginpage.html"
        if (!usersessioncookie)
          redirect_to http://loginpage.html

Well, in the example you posted, you don't have quotes around the second
"http://loginpage.html/"... though maybe that's just a error in copying.

Other than that, maybe try some logging in there to see what's happening...


PS: Oh, one more thing... I think most people usually do their logged in
check in the ApplicationController (application.rb) and hook it up as a
before_filter for all their actions. That way you won't have to put
ifLoggedIn in every single view.

Chris Earle wrote: