This project is read-only.

How to save language selection in a cookie

May 19, 2013 at 10:47 PM
i have a simple question. Is it possible to save language selection from LanguageSelectorForWebForm
into a cookie and when the new page loads LanguageSelectorForWebForm will have language value from a cookie ?

Im doing a 1;1 site translation.
May 20, 2013 at 9:14 AM

Yes, it is possible. You would have to download the source code of the package and recompile if of course, because you would need to change the codebehind of the langauge selector ( to work this way. Then, you would also need to change the razor or xslt scripts to work using cookies instead of reading the language from the URL.

If I may, I would like to advise against this setup though. The method would not work for visitors who block cookies from their browser. Moreover, if you do it so that you remove the language parameter from the URL, you will no longer have unique URLs pointing to each linguistic version of your pages, which is bad for S.E.O. As a matter of fact, best practices tend to point in the opposite direction these days, making the language selection information part of the URL path or domain instead of just a parameter. (I have written about how to make Polyglot work this way:

Best regards,


May 20, 2013 at 12:29 PM
First of all i want to thank you on your fast reply.

Thank you for directions what would i need to do.

I understand if user blocks cookies this will not work, I was also considering to make a global variable and store selected language in it - do you think is this posible ?

Main reason why I want to set it up like that is simplicity when user needs to edit content it's much simpler this way, but since you are suggesting that this is not a good practice I will reconsider.

Best regards,

May 20, 2013 at 1:02 PM
You're welcome!

I'm afraid that storing a global variable on the server would not work. You see, http is stateless, meaning that you will need to use either a cookie or a URL parameter (like the Polyglot package does). Otherwise your system will not "remember" the language each user has selected, even while the users are clicking from one page to the other.

Best regards,