Question

i am developing a multilingual site in expression engine. and i am using different domains for different languages versions of site eg: www.site.en, www.site.jp, etc.

now i want to track the visitors language preference that is i want to find out which of these domains was visited by that user/system(no user login feature) in the last. suppose i visit www.site.com and i switch to www.site.jp and close my browser.

so next time when the user visits any of these domains i want to redirect the user to the domain(www.site.jp in this case) he visited last.

The problem is that i can't set a cookie for another domain.
Neither do i have a user login feature.
Nor do i want to user third party cookies coz it won't be reliable system.

Was it helpful?

Solution

Right before redirect user to www.site.jp, you should set a cookie in www.site.com. Therefore, when user visit again in www.site.com the cookie is readable in your PHP script, and you can redirect again.

If user visit directly into www.site.jp, you need not to bother that, cause the site is already in Japanese.

OR
always redirect to www.site.com/setcookie?lang=xx,
before any domain switching and right after cookie set, do the necessary redirect

So, in theory, www.site.com always keep a cookie for the last selected language, and you can use that to redirect to www.site.xx

OR
instead using multiple domain name, using seconds level directory for separation, like

www.site.com/en
www.site.com/jp
www.site.com/zh
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top