Setting Cookie using url parameter value

Hi guys, I'm having some trouble with a custom theme for this site:

It's a (subdirectory) multisite with a separate site for a number of countries.
There is a country select menu in the header so that users around the world can select their relevant site easily.

The idea is that once they have done this once, a Cookie is set with a value of their country code. Next time thy visit the main homepage, the cookie value is used to redirect them automatically to their country's site.

I've set the 'country select' menu items to load the main homepage, adding a 'region' parameter like this example for choosing 'Italy':
This parameter value should then be used to set the cookie value that's used to determine the redirect location.. However the cookie isn't being set..

Here's my code:

Any ideas what's going wrong!?
Hope you can help
Thanks, Martin