Skip to content Skip to sidebar

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

Problem:
You are using WPML with Beaver Builder and have set up separate domains for different languages. However, when you switch languages in the WP Admin panel, the 'wp-wpml_current_language' cookie does not update correctly. It shows 'en' instead of 'ja', and when switching from the English domain to the Japanese domain, two cookies with values 'en' and 'ja' appear.
Solution:
We have identified that this issue might be related to custom code that alters WPML's default behavior. We recommend checking any custom code that might interfere with WPML's handling of cookies. Additionally, we suggest using WPML Hooks as a possible workaround for managing cookies across different domains. You can find more information on WPML Hooks here: WPML Hooks Reference.
If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at WPML 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 0 voices.

Last updated by Andreas W. 1 month, 3 weeks ago.

Assisted by: Andreas W..

Author Posts
May 28, 2025 at 3:16 pm #17084327

Vipul Jadvani

Background of the issue:
I'm using WPML + Beaver Builder on my website. WPML stores the current language in a cookie named 'wp-wpml_current_language' with the language code as its value. I've created separate domains for different languages: hidden link for Japanese and hidden link for English.

Symptoms:
When I change the language to Japanese while logged into the WP Admin panel, the cookie 'wp-wpml_current_language' still shows 'en' instead of 'ja'. Additionally, when switching from the English domain to the Japanese domain, there are two cookies named 'wp-wpml_current_language' with values 'en' and 'ja'.

Questions:
Why does the 'wp-wpml_current_language' cookie not update to 'ja' when I change the language to Japanese?
Why are there two 'wp-wpml_current_language' cookies with different values when switching domains?

May 28, 2025 at 7:17 pm #17085304

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

This behavior is likely due to cookie scoping rules:

- Cookies are scoped by domain.
A cookie set by hidden link cannot be read or overwritten by hidden link, and vice versa.

So, when you're on hidden link (English):

The cookie wp-wpml_current_language= en is stored for that domain.

Then, when you switch to hidden link (Japanese):

A new cookie wp-wpml_current_language= ja is set for the Japanese domain.

If you're inspecting cookies across both domains (like using browser dev tools while switching tabs), it may appear that there are two cookies with different values, but each one belongs to its respective domain, not both.

Conclusion:
The cookie doesn't "update" in the usual sense because you're crossing domains. You're actually seeing two separate cookies scoped to different domains. This is expected behavior in a multi-domain setup.

Best regards
Andreas

May 29, 2025 at 5:43 am #17085996

Vipul Jadvani

Hi
I agree with your answer. But the issue is totally different. I've created a custom filter where I get the current language using the "$current_language = apply_filters('wpml_current_language', null);" filter. I switch the language to Japanese, but still I get 'en' instead of'. That is why when I open up my blog page, I load the latest blog list with pagination, and I'm using the "$current_language = apply_filters('wpml_current_language', null);" filter to get the current language, but I am getting 'en' instead of 'ja', and also if I look into the cookie, then it is also shown as 'en' instead of 'ja', and the result is shown in the EN language blogs rather than JA language.
I am sharing the screenshot hidden link URL for your reference.

Screenshot from 2025-05-29 10-58-46.png
May 29, 2025 at 9:26 am #17087217

Vipul Jadvani

Hi
Sorry, I forgot to mention that I've created custom AJAX to load my blog posts and also show the English blog post while the user is logged in but actually I'm on the Japanese language.

May 29, 2025 at 5:55 pm #17089430

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

My apologies, but if you use custom code to alter the default behavior of WPML then our support team can not take responsibility for this.

What I can offer to do is run a test on a local server try to recreate the duplicated cookie issue and then escalate to the second-tier support team.

As mentioned earlier, it might usually be expected that each cookie loads for each domain, and remains saved in the same browser session, but maybe we could offer a workaround in this case by using one of our WPML Hooks.

https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

I will run such a test locally today and then get back to you.

Best regards
Andreas

May 29, 2025 at 9:46 pm #17090034

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

The reported issues might be related to your custom code implementation.

I took a test on a local test site using different domains per language and can not confirm this issue.

See screenshots.

english domain.jpg
domain.jpg