Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client wanted to know how to set WPML to save the selected language in a cookie so that it remembers the user's selected language even after the browser is closed.
Solution:
We explained that WPML's *Automatic redirect based on Browser language* feature only redirects users based on their browser language for the first visit and cannot force users to stay in a selected language if they choose a different language URL. This is not possible with the default features of WPML.
We suggested that the desired functionality might be achieved through custom coding, but we have not tested this solution. We provided links to resources that could help with custom coding:

We also mentioned that our support policy limits assistance with custom coding, and we directed the client to our support policy for further information: WPML Support Policy.

Please note that this solution might be irrelevant due to being outdated or not applicable to your case. If this is the case, we highly recommend checking related known issues at WPML Known Issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket in our support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Bigul 10 months, 2 weeks ago.

Assisted by: Bigul.

Author Posts
March 18, 2024 at 10:02 am #15420014

shayL-4

Hi,

How can I set WPML to save my selected language in the cookie, so that if the user closes his browser, it will remember his selected language the next time he enters the site?

March 18, 2024 at 1:34 pm #15421392

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Shay,

Welcome to the WPML support forum. I will do my best to help you to resolve the issue.

Please visit the following documentation to learn more about WPML Cookies.

https://wpml.org/documentation/support/browser-cookies-stored-wpml/

Maybe the *Automatic Redirect Based on Browser Language* feature will be helpful for you - https://wpml.org/documentation/getting-started-guide/language-setup/automatic-redirect-based-on-browser-language/

--
Thanks!

Bigul

March 18, 2024 at 3:12 pm #15422179

shayL-4

Hi,

I'm looking for a solution the will keep the user preferred language on cookie, so if a user select do display the site in "Hebrew", it will show the site automatically in Hebrew every time he will open the browser and enter the site (Hebrew will become his default site language).

You've suggested to use the "Automatic redirect based on Browser language", but what if i use English version of chrome, but would like to see the site in Hebrew every time i enter the site?

I'm looking for a better solution that will use db or cookie to store selected language.

March 19, 2024 at 8:48 am #15424639

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Shay,

Thank you for the updates. I will consult with our team for an expert opinion on this and get back to you soon. Please wait.

--
Thanks!

Bigul

March 20, 2024 at 8:17 am #15429818

shayL-4

Hi,

Do you have any updated regarding saving the selected language?

March 20, 2024 at 3:31 pm #15432722

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hi Shay,

The *Automatic redirect based on Browser language* feature will redirect users based on browser language only for the first time. WPML can't force the user to stay in one language even if they select the 2nd language URL. So that is something practically not possible with default features.

Please note that this is a custom requirement. It may be possible via custom coding like the following. But we haven't tested it yet.

https://stackoverflow.com/questions/48121717/wordpress-redirect-based-on-the-presence-of-a-cookie

https://wpml.org/faq/how-to-get-current-language-with-wpml/

Sorry, as per our support policies we have limitations for custom coding. Thank you for your kind understanding - https://wpml.org/purchase/support-policy/

--
Thanks!

Bigul