One thing you should know is that different domain path don't share cookies between them, so the cookie solution will not help you too much with this.
Cookies is the best solution for anonymous users and I think it will be difficult for you to approach a solution for them.
Once a user is logged in, the change is automatically done inside the user's profile, so it doesn't mother the portal alias, the language will be selected from the user profile. One important thing is to only enable specific detection modes and to set the order of detection correctly.