This is an example of how to use Authlogic in a rails app. Authlogic is an object based authentication solution that handles all of the non sense for you. It's as easy as ActiveRecord is with a database.
This application live: http://authlogic_example.binarylogic.com
Quick tutorial on how to build this application here: http://www.binarylogic.com/2008/11/3/tutorial-authlogic-basic-setup