Persistant (sticky) URL parameters?

Hi, How can easily add a "persistant" or sticky parameter to my routing, eg something like     http://www.mysite.com/controller/action?theme=blah or     http://www.mysite.com/controller/action?loggedin=1

I don't want it in the session, because each browser window should have it's own settings. I want to add it at the application level and not have to visit each action to add it on.

The main purpose I have for this is to implement a kind of slimmed down theme if the site is visited via a special URL (because it's embedded in a frame). However, I don't want to use a cookie because if the user visits the site normally then this should show the full theme. I might have also a similar use for some "cache busting" URLs where I need to make a page slightly different for some reason, eg admin logged in, adding "?admin=1" or something trivial to the URL makes it easier to bust the caching so that this page is different to the standard URL

What's the easiest way to implement this so that the param remains in place (sticky) for each URL (once set the first time)

Cheers

Ed W

Cookies will be your friend here.

chrisfarms wrote:

Cookies will be your friend here.    I don't see how I can use a cookie which affects only one browser window, but not one in the tab next door? I would actually quite like to know how to do this for other reasons, eg open up a second browser window and log in as a different user without affecting the user I logged in as on a different browser window...

If it's possible then please share

Ed W

Here's a snippet of where I do the exact same thing. You have to use or add your 'sticky_params' hash to your options hash on all the link_to methods on that page.

If you use it all over the place you could probably extend the link_to method in a better way to directly access a params hash in your controller that is always appended to your options hash.

<% sticky_params = { "order_by" => 'Name' , "noun_type" => @noun_type } %> <th><%= link_to( 'Name' , sticky_params ) %></th>

Shane Sizer

Ed, did you try using default_url_options method in controller? it should keep all params defined..

best, Bojan

Ed W wrote: