Change language programmatically after login
It should not be necessary to do it from code, as one of the settings present in admin/config/regional/language/configure allows to set the language to the one selected from the users in their user profile settings.