How to setup a Session and use its data from other classes?

I am trying to do an authentication where I have :
session["User"] = User.authenticate(@params["name"],

and the program continues on if the authentication is correct. Now if
later on in the session I want to access "User"'s data (using active
directory) I try to use:

if session["User"].id == 0
   //do something
  //do something else

Now I always get id =0 so i must have set the session wrong or not at
all? Here is how i do the authentication:

if session["User"] = User.authenticate(@params["name"],
      if session["return_to"]
        session["return_to"] = nil
        redirect_to :controller => "NewController"
      flash[:error] = 'Invalid user name and/or password.'
      redirect_to :action => "index"

I try to use session["User"] elsewhere to get data but no good. Can
someone help? thanks!

First question is "Does your User.authenticate return a user object to
be stored in session?"

From the sparse look we have at the code, that's where I'd be looking

No, the User.authenticate does :
User.find(first,....) to check for user authentication. How do I
return the object? with this way? sorry i am bit new at this....

it also seems the ID is 0,1 and apparently in ruby that is true/false
class... so after I set the session correctly do I just do :

if session["User"].id == true
//do something