script/console and session

I am trying to debug my application using ruby script/console. Once I am in the console, I type session[:user_id] and I get and undefined local variable error. If I use a view to post the session[:user_id], I get no error. Any idea why this is happening. Help is greatly appreciated.

you can use session only in your views and controllers. since a session is basically a hash that holds a value, for example your session[:user_id] = some integer.

So in rails console, you can simply pass a value that you method expects. lets say you have a method called find_user_data(session[:user_id) that expects a session[:user_id]

in the console, instead of calling it like find_user_data(session[:user_id) you can simply call this as find_user_data(1)