Use php cookie in all sub domain

I am using cakephp 2.x for my main application and wordpress for blog, now my main application is on my domain called example.com and my blog is in sub domain called blog.example.com. i want to login user in my blog site also when user login in my main site (example.com).

in cakephp i have use

Read More
ini_set('session.cookie_domain', '.example.com');

in my myapp/app/Config/bootstrap.php

and

$this->Cookie->domain = '.example.com';

in beforeFilter() of my appController

while in WP i had used

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

Now scenario is,

  1. When i open example.com first and login with my username/password and then after i open blog.example.com then my blog site show me as logged in user (i have just different header menu for logged in user and not-logged in user)
  2. When i open my blog.example.com first, then after i open example.com and login in example.com and refresh the blog.example.com then it won’t display header for login user(i.e not login the user, means not detecting the session cookie of main domain).

i determine the logic like (i’m not sure but), if wp site open up first then it create it’s own session cookie and if cakephp site open first then wp site uses session cookie from that. but what for point 2.

can anyone help me please?

Thanks

Related posts

2 comments

  1. header("Set-Cookie: cookiename=cookievalue; expires=thus, 14-march-2015 23:39:49 GMT; path=/; domain=subdomain.example.net");
    

Comments are closed.