• Resolved lacroixca

    (@lacroixca)


    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?

Viewing 1 replies (of 1 total)
  • Thread Starter lacroixca

    (@lacroixca)

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘Cookie settings for session across WPML subdomains using custom AJAX login’ is closed to new replies.