• Resolved feedmeastraycat

    (@feedmeastraycat)


    I have noticed an issue with this plugin and WPML. I have tested it on a clean install.

    • WordPress 6.3.1
    • Cookies och Content Security Policy 2.17
    • WPML Multilingual CMS 4.6.6
    • WPML String Translation 3.2.8

    When a logged in user switch language and loads a page the “wp-wpml_current_language” cookie is first set to the selected language, for example “en”, but then when js/cookies-and-content-security-policy-error-message.php is loaded the cookie is changed back to, what I guess is the site default language, in my test case “sv”.

    When loading the page in Chrome I can see the cookie change in real time.

    In the request headers to this php file the cookie is “wp-wpml_current_language=en”. But in the response header there is a “Set-Cookie” header with “wp-wpml_current_language=sv; …”.

    Im guessing it is something with how this php file loads WP by including the wp-load.php file but then it just outputs the javascript content without using filters or actions. So Im guessing some WPML hooks are not triggering. Somehow. But Im guessing (swedish “killgissar”) a bit. ??

    But deactivating the cookie plugin removes the issue. And adding a “die;” row in the top of js/cookies-and-content-security-policy-error-message.php (line 8 for example) also fixes the issue. But then, of course, the error message js thing is not included.

    I can only recreate the issue when Im logged in. It works as expected when browsing the site as a guest.

    Maybe a better solution here would be to render the js file and store it in the uploads directory anytime when any of the plugin settings are changed in wp-admin. Would also make the request quicker and easier to cache.

    We use this plugin on a lot of sites we do. It works well in its simplicity. Not a lot of sites with WPML though. And this is the first time noticing the issue. Not sure when it appeared. Feel free to reach out to me on [email protected] as well as public responses here if you have any ideas.

    /David

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Johan Jonk Stenstr?m

    (@jonkastonka)

    Sounds really strange since the plugin doesn’t block first party cookies. Is WPML setting cookies from some other domain? Is your setup of the language sites with domains/subdomains?

    Is there any way I can see this in action? You can email me on [email protected] if you don’t want to publish the URL publicly.

    And the idea to store the the error message as a js-file is very good. I’ll look into that.

    Thread Starter feedmeastraycat

    (@feedmeastraycat)

    @jonkastonka Yeah. Strange indeed. I think its just how the plugin loads WP that causes WPML not to do its stuff completely.

    If the javascript was loaded fully through WP. For example if you had site.com/?load-cookie-error-message-stuff=1 as the javascript URL. And then used for example the template_redirect action to output the javascript. It might not be an issue.

    Im thinking that what ?js/cookies-and-content-security-policy-error-message.php does now is that it boots up WP to some extend. But it does not let everything load up completely.

    But this is totally guessing here. I havent tested that far (yet). ??

    Im gonna have a look if I can add you as a user to the site where we noticed it.

    Thread Starter feedmeastraycat

    (@feedmeastraycat)

    @jonkastonka Just checking, did you get my email? Let me know if you have time to look at it soon(ish). ??

    Plugin Author Johan Jonk Stenstr?m

    (@jonkastonka)

    I had missed it, but found it now. I’ll take a look at it when I get some time on my hands.

    Thread Starter feedmeastraycat

    (@feedmeastraycat)

    I believe this is fixed with 2.19. Great job.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WPML issue, language cookie reset by cookie php js file’ is closed to new replies.