In my Rails application, I have a login page. After this user logs in, which is best for my application to continue tracking the person who is logged in. For example, if a user navigates to different pages, my controllers / actions will lose track of that user unless I continue to pass a variable between each page that the user visits. Is there a better way to do this? Should I use a variable sessions?
sessions
Yes, sessions are exactly what you are looking for.
session["user_id"] = user_id
And to get the current user on another page (if your model is called User):
@current_user = User.find(session["user_id]")
Think hard on the plugin to manage this.
There are several, for example, calm authentication .
It gives functionality current_userand logged_in?.
current_user
logged_in?
There are some great stones that do this.
Devise
Authlogic