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
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,
- When i open
example.com
first and login with my username/password and then after i openblog.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) - When i open my
blog.example.com
first, then after i openexample.com
and login inexample.com
and refresh theblog.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
You can do like this :
This is not necessary to set domain name.if you not set domain name then it auto save domain name as ‘/’.
Please check this url also.
http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html