save url parameter in a session

Hi, I am a newb.

Lets say I have url abc.com/?animal=cat. What I need to do is save the param in the session file but still have it available to other controllers. I can get it to work within one controller with:

session[:animal] = param[:animal]

but I cannot get it to save and be used by other controllers. I can hack it by adding:

session[:animal] = "cat"

in the application.rb and adding a before filter to the controller. How do I add a param from a url in a session to be used by all controllers?

Thanks!

Hi, I am a newb.

Lets say I have url abc.com/?animal=cat. What I need to do is save the param in the session file but still have it available to other controllers. I can get it to work within one controller with:

session[:animal] = param[:animal]

There's no reason that shouldn't work. If there's something you're
doing wrong you haven't shown us that bit yet.

Fred

So sessions are not cleared out controller to controller? I found another way (prob. a better way), I am using the redirect_to to pass the variable. The funny thing about problems is that you need to know what the question is before you can solve it I guess... Thanks!

So sessions are not cleared out controller to controller?

Nope. would rather defeat the point of the session

I found another way (prob. a better way), I am using the redirect_to to pass the variable. The funny thing about problems is that you need to know what the question is before you can solve it I guess... Thanks!

That sounds like a sane way to do it.

Fred