Remember users Taxonomy choice, such as which city to filter the site by? I want to convert an existing site to support the selection and association of Cities. Each node can be associated with a City, and the Cities will be selectable as tabs at the top of each page.

Lets say the City Taxonomy is:


All Cities (mainly used for old content the client doesn't want to convert)
London
New York
Paris


If a user browses to any City's front page then that will stamp that city in their cookie/user profile, such as:


site.com/all-cities
site.com/london
site.com/new-york
site.com/paris


Then when the user returns to the site front page site.com/ without a city specified, they'll be redirected to their remembered front page.

The site does not support user accounts however, so only anonymous users will visit, so it only needs to use cookies rather than store data in the DB per user.

Importantly, on top of this, the site is using 1 hour page caching due to relatively low traffic and poor page load speeds, so the redirect will need to run before the cache.

What is there a standard Drupal way to achieve the above, or will it need to be entirely custom in order to run outside any form of caching?

Thanks for any advice!
I would create a custom module and.


Save the choice in the users session (sessions is mapped to a cookie)
Use hook_boot to do the redirect, a simple drupal_goto should be enough.


Using sessions is more simple, but depending on your settings the data will persist for a shorter period of time than cookies. But that might be a good thing.