khromov / wp-wpml-geoip-browser-language-redirect

GeoIP Redirector for WPML (WordPress)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cookie _icl_current_language always changing to en

nikolasuperscript opened this issue · comments

Hello,
As I noticed, redirection works only on first load, after refreshing initial url, it doesnt redirect anymore.

I saw that in cookie section of chrome, it first puts the correct language code, but after refresh, it changes the value to the default...

Any idea ? I am new, I dont know if I asked the question the right way...

@nikolasuperscript Only redirecting on the first page load is the intended behaviour, we don't want to force users into a potential redirect loop or force them to use the site in a specific language based on their location.

If you have any other issues, feel free to post them here or in a new issue.

But if they come again on our website, they will have content in default langauge, it wont redirect them again ?

@nikolasuperscript If they return back the next day and again go to the "wrong" language, they will not be redirected again, this is correct.

The cookie lifetime is set by WPML (not sure if it's configurable though). It seems to be 24 hours. But you can change it manually here:
https://github.com/khromov/wp-wpml-geoip-browser-language-redirect/blob/master/js/browser-redirect-geoip.js#L59

If you want to debug it, check the presence of the _icl_visitor_lang_js cookie and its lifetime.