Seemingly successful attempt to implement one login for several sites
-
I have several WordPress sites (version 2.5.1) that are related, and I want a user to be able to log in to any one of them, and then have access to the rest of them.
Each site is accessible via URL’s like these:
https://mysite.tld/site1
https://mysite.tld/site2
… etc. …I have made an attempt to implement this which seems to be working, but it is so simple that I am afraid that I might be overlooking something which will cause problems. I’m hoping that some of you could look this over and show me any flaws that I might have in this procedure.
Although each site uses a separate database table prefix within the same database, every user appears in each site’s database with the same user ID and password.
Then, I put the following code in each site’s wp-config.php:
$baseurl = 'https://mysite.tld'; $cookiehash = md5($baseurl); define('USER_COOKIE', 'wordpressuser_' . $cookiehash); define('PASS_COOKIE', 'wordpresspass_' . $cookiehash); define('AUTH_COOKIE', 'wordpress_' . $cookiehash); define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', $baseurl . '/' ) ); define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', $baseurl . '/' ) ); define('SECRET_KEY', 'Site-wide-secret-key-string'); define('SECRET_SALT', '!!!Site-wide|secret|salt|string(%j*6hUsdg&$()%asfd%^+|aAGv{aF35t&');
Once I put this code in place, users are indeed able to log in to one site and then have access to all the rest. Do any of you see any problems with this methodology?
Thanks in advance.
- The topic ‘Seemingly successful attempt to implement one login for several sites’ is closed to new replies.