Re: Accessing session variables

Frederick Cheung
2006-11-15T09:09:08Z

Looking at the dump of the session in your first message you''ve put the
whole user object in the session,
so to get the id of that user you''d have to do session[:user].id

In general you should be careful about what you put in the session
(beyond basic stuff like hashes, arrays, strings, numbers etc...). The
main reason is that if your User class changes significantly then rails
can be unable to unserialize the session from wherever you''ve stored
it,
leaving your users with a rather unhelpful error message. In this case
I''d just put the user id in the session

Fred