Thursday, February 7, 2013

Single Login For Multiple Wordpress Domain

WordPress is web software you can use to create a beautiful website or blog. We like to say that WordPress is both free and priceless at the same time.

One Login For Mutiple Wordpress Blog Or Site Using Single Database.In order to be able to share a session cookie between both sites just use below code for it.



1) Sub Domain
    Example : example.com , test.example.com , main.example.com
          If you use sub Domain you can follow this step:

Step 1 : Open Config File (Main Domain) and add below code.

$baseurl = 'http://example.com'; // replace with your main blog url
$cookiehash = md5($baseurl);

define('COOKIE_DOMAIN', true);
define('ADMIN_COOKIE_PATH', '/');
define('COOKIEPATH', '/');
define('SITECOOKIEPATH', false);
//define('COOKIEHASH', 'vy48u9w38868t7t99jh8g137x221r5h1h8');
define('COOKIEHASH', $cookiehash);
define('AUTH_KEY',         'qKuU:a]Zc9PfkXIN@e%[>)kl+EjNK!M; AGerZfz_LdK)LEF[v@LGx4efm-u)v`y');
define('SECURE_AUTH_KEY',  'aCDUFGo3[eKwh^h+xGZF^+J#XS|{BoW_on;}$pm*qWH4nWy`QxyaT^uirF!*`*O3');
define('LOGGED_IN_KEY', 'mywu969v3tcf2uer82vxisx8k6sq2neib5qs1qt4sx383slslb5t1xep12hbtcxs');
define('NONCE_KEY', 'bde6j26r93lvwmgwydw7x3kp74r5299q8vxe832y7r616lf215142e5t4vc55j36');
define('AUTH_SALT', '3856m559klvidrx34fi574ct32r94x77bepr7638jmuw22d29883i82k76un2tm4');
define('LOGGED_IN_SALT', 'jq4p67bv772nd73w4zm6286552x755v6293qpj5fbe34fxy894trdu77h38586n2');
define('SECURE_AUTH_SALT', 'i9hlmd67n21j2u485645in9vu6v92itgfmja6bjfbc36gqc673svlis9u789316p');
define('TEST_COOKIE', 'TEST_COOKIE'.COOKIEHASH);


Step 2 : Open Config File (Sub Domain wordpress setup) and add below code.

 $baseurl = 'http://example.com'; // replace with your main blog url
$cookiehash = md5($baseurl);

define('COOKIE_DOMAIN', '.example.com');
define('ADMIN_COOKIE_PATH', '/');
define('COOKIEPATH', '/');
define('SITECOOKIEPATH', false);
//define('COOKIEHASH', 'vy48u9w38868t7t99jh8g137x221r5h1h8');
define('COOKIEHASH', $cookiehash);
define('AUTH_KEY',         'qKuU:a]Zc9PfkXIN@e%[>)kl+EjNK!M; AGerZfz_LdK)LEF[v@LGx4efm-u)v`y');
define('SECURE_AUTH_KEY',  'aCDUFGo3[eKwh^h+xGZF^+J#XS|{BoW_on;}$pm*qWH4nWy`QxyaT^uirF!*`*O3');
define('LOGGED_IN_KEY', 'mywu969v3tcf2uer82vxisx8k6sq2neib5qs1qt4sx383slslb5t1xep12hbtcxs');
define('NONCE_KEY', 'bde6j26r93lvwmgwydw7x3kp74r5299q8vxe832y7r616lf215142e5t4vc55j36');
define('AUTH_SALT', '3856m559klvidrx34fi574ct32r94x77bepr7638jmuw22d29883i82k76un2tm4');
define('LOGGED_IN_SALT', 'jq4p67bv772nd73w4zm6286552x755v6293qpj5fbe34fxy894trdu77h38586n2');
define('SECURE_AUTH_SALT', 'i9hlmd67n21j2u485645in9vu6v92itgfmja6bjfbc36gqc673svlis9u789316p');
define('TEST_COOKIE', 'TEST_COOKIE'.COOKIEHASH);


define('CUSTOM_USER_TABLE', 'wp_users');
define('CUSTOM_USER_META_TABLE', 'wp_usermeta');


Step 2 : Open capabilities.php File (Sub Domain wordpress setup) and add below code.
(C:\xampp\htdocs\wordpress\wp-includes\capabilities.php)

Goto line no:709 and change below line

$this->cap_key = $wpdb->prefix . 'capabilities';

Change to : (main wordpress database prifix)

$this->cap_key = $wpdb-> 'wp_capabilities';  
 

No comments:

Post a Comment

Thanks....