That's what it looked like. Read the value of the "city" cookie, check whether a subdomain by that name exists, and redirect accordingly. Presumably the user can still manually select some other city, or start over with a clean slate ("city" = 0 or www. or unset or, heck, probably a dozen different approaches).
Did this start out as someone else's code?