0

I am trying to enable a custom login session across both English and French subdomains.

-WordPress is installed only on domain.com.

-There are only en.domain.com and fr.domain.com as WPML subdomains, with redirects (as instructed here: https://wpml.org/faq/server-setting-for-languages-in-different-domains/).

-No issues with navigation across subdomains.

My AJAX custom login successfully signs in the user with wp_signon(). The AJAX request successfully returns 4 cookies. However, session is not initiated; on page refresh, user is still not connected.

When I login through /wp-login.php, the session is properly initiated.

It seems like the solution lies in the proper configuration of COOKIE_DOMAIN, COOKIEPATH & SITECOOKIEPATH settings:

define('COOKIE_DOMAIN', '.domain.com');
define('COOKIEPATH', '/');
define('SITECOOKIEPATH', '/');

Anyone has a solution for this?

0

I continued looking for an answer elsewhere, and found one.

Basically, the "cookie domain origin policy" was the issue, not sign-in process. I was calling domain.com/wp-admin/admin-ajax.php from a subdomain fr.domain.com.

I called fr.domain.com/wp-admin/admin-ajax.php instead, and that worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.