Andreas Schneider wrote:

Hi all,

perhaps I am on the wrong path - because I come from the ASP world :slight_smile:

I want that my app checks on every page if my user is logged in or not.
I have 2 cookies set in my signin process - which works great.
now I want to set a global var if a user is logged in or not
I do that in the application controller

class ApplicationController < ActionController::Base

    $login_user_id = cookies[:user_id]
    $login_user_sid = cookies[:user_sid]
    if $login_user_id != ""
      $login_ok = true
      $login_ok = false


but this will not work - he cant access the cookies

error >> undefined local variable or method `cookies' for

what I am doing wrong?

thanks for any help in my path to escape the MS ASP world :wink:


You could write an action that just checks those cookies...

class ApplicationController < ActionController::Base

  def login_ok?


Then in some other action in say, your store_controller? use

def show_store
  if login_ok?
    render :layout => 'store'
    flash[:warning] = 'not allowed there!'
    redirect_to :action => 'not_allowed'

Or something similar, I'm not very big on cookies, but
this seems like it should work :]

Gustav Paul