Store anonymous user selection temporarily until registration
I want to let my first time visitors to first select a city.


okk... so is this selection apart of say their Registration Process, if so you have 0 code to write? or some other random landing page on the site you are funneling new traffic too ... in which case you have to write some code ...

Anyways I would:


Add a field like user_location to their Account Profile fields under Admin -&gt; Account Settings -&gt; Manage Fields ... or use the Profile module to add such a field to a profile. There are "location" contributed modules for location type drupal Fields as well ... not sure what or how you want to store a "city" reference (string, geocode, zip, country + city, whatever).
Then that field will be available everywhere as apart of the $user object.


If, you want this field to be collected before a user has registered (or separate from the registration process -- any fields in a users account settings can be made apart of the registration process). I would:


create a simple module and define a FAPI form with a country list. The list_predefined_options module may help you make this list and manage it in code ...
store the value in the users Cookie session value. Upon login use hook_user_login to look for the cookie value on 1st login to update the account user_location field with the session value.


Good luck.