# Using session variables vs passing parameters via URL

**URL:** <https://www.ruby-forum.com/t/using-session-variables-vs-passing-parameters-via-url/156199>\
**Category:** Rails\
**Created:** [December 22, 2008, 6:02pm UTC](https://www.ruby-forum.com/t/using-session-variables-vs-passing-parameters-via-url/156199 "2008-12-22T18:02:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [December 22, 2008, 6:02pm UTC](https://www.ruby-forum.com/t/using-session-variables-vs-passing-parameters-via-url/156199/1 "2008-12-22T18:02:07Z")

</div>

Hi,  
I have been tweaking my index view in order to narrow down the amount of  
data displayed. The obvious first step was to add will-paginate, but  
then I  
added a couple of select boxes to narrow things down a bit more based on  
categories. Somewhere in the midst of all of this I discovered the way  
cool  
feature of named routes that allows me to pass parameters into the named  
route. So I am using things like new\_document\_path(:category =\>  
@category,  
:prefix =\> @prefix) in order to pass the values of @category and @prefix  
from my “index” view into my “new” view.

I am trying to do the same thing with the named route in a form (i.e.  
form\_for (document\_path(:prefix =\> @prefix, ;category =\> @category,  
:page =\>  
@page) …) and am running into some problems. It may be the case that  
I  
cannot use this feature for the #create action. I’m not sure yet. But  
as  
I’ve started thinking about this I’ve started to wonder if I’m going  
down  
the best path.

Would it make more sense to store @prefix, @category, @page, and  
whatever  
else I think I might want to pass around in the session? Or should I  
keep  
going down this route?

I should point out that the purpose of these parameters is solely to  
narrow  
down the number of items displayed. They don’t affect anything other  
than  
the view the user sees as (s)he navigates back and forth between the  
#index  
view, the #new view, the #index view for some other controller etc…

–wpd

---

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [February 1, 2009, 11:55pm UTC](https://www.ruby-forum.com/t/using-session-variables-vs-passing-parameters-via-url/156199/2 "2009-02-01T23:55:47Z")

</div>

Any one have any thoughts on this one?

Thanks

---

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [February 2, 2009, 12:57am UTC](https://www.ruby-forum.com/t/using-session-variables-vs-passing-parameters-via-url/156199/3 "2009-02-02T00:57:12Z")

</div>

Hi Patrick,

Session variables are awefull, please don’t use them.  
Just think of a user passing the url to another user expecting  
that the other will see the same content but with weird session  
variables that wouldn’t happen.

ciao, tom

On Dec 22 2008, 6:01 pm, “Patrick D.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Would it make more sense to store @prefix, @category, @page, and whatever  
> else I think I might want to pass around in the session? Or should I keep  
> going down this route?

–  
Thomas R. “TomK32” Koll \<\> [http://ananasblau.com](http://ananasblau.com)  
just a geek trying to change the world  
[TomK32 (Thomas R. Koll) · GitHub](http://github.com/TomK32)
