I'm building a site in multiple languages (Italian and English) and I would like to ask you to intervene on the code to add selections 'if' to my queries to the user's local language. At first I place conditions using as a reference global $ language but I understand that it is wrong as it does for the whole site and not a single user. I saw on the internet that you can use sessions but how do they do? I would also switch to change languages. I have no idea how to do. I went in configurations -> REGIONAL AND LANGUAGE -> languages -> detection and selection .. here that I have to give exactly? How should I do help me please!

1 Answer 1


If the user is logged in, you can the global $user variable. The language object is then $user->language. For an anonymous user, you can use a session variable or a cookie. There's a module to use cookies: Language Cookie

To use a session variable: On the "Detection and Selection" configuration page, set "Session" as the first detection method. To set up the variable, click the "Configure" link on that page. You should see Session language detection configuration

Then you just need links to set the user's language. Something like

http://yoursite.com/?language=en and http://yoursite.com/it?language=it at the top of the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.