johnbillion / user-switching

WordPress plugin that provides instant switching between user accounts.
https://wordpress.org/plugins/user-switching/
GNU General Public License v2.0
187 stars 49 forks source link

COOKIE_DOMAIN causing 404 #58

Closed neillaferty closed 4 years ago

neillaferty commented 4 years ago

Hello,

We are setting the COOKIE_DOMAIN in wp-config.php to allow support for subdomains. For example:

define( 'COOKIE_DOMAIN', '.mysite.com' );

This appears to break the user switching plugin. Specifically, we receive a 404 or "could not switch users" error when trying to switch.

Do you know of any workaround for this?

Thanks! Neil

johnbillion commented 4 years ago

Can you provide some more info about what your intention is for supporting subdomains? What's your setup look like?

neillaferty commented 4 years ago

Hi John,

Thanks for the reply.

We need to access WordPress cookies such as wp_login*** in our sub-domain in order to validate and fetch User Info through WordPress rest api. In order to the browser pass these cookies to our sub-domain, we need to set the cookie's domain to allow sub-domains like ".my-site.com"

We have an app on a subdomain that needs to scrape this information.

I tried clearing all browsing data, starting from a private tab, etc., all with the same result.

Thanks! Neil

johnbillion commented 4 years ago

My understanding of the behaviour of cookies on subdomains is that the leading period on the domain is not needed in order to allow a subdomain to access a cookie, as long as the cookie domain is set, which it is.

By that I mean define( 'COOKIE_DOMAIN', 'mysite.com' ) without the period prefix should work and allow your subdomain access to the cookies.

Aside from that, I don't know why this configuration doesn't work and it's not something that I can spend time looking into, sorry!

neillaferty commented 4 years ago

Hi John,

I see you closed the issue which is fine. Thought you might like to know, it turns out the error was really a 502 so we used your replies on other issues involving 502s to resolve the problem. Working fine now.

Thank you, be well!

Neil

johnbillion commented 4 years ago

Thanks for the update, that problem does pop up from time to time.