Reputation: 3091
I am trying to figure out how to use the php function setcookie() to set a cookie in domain X and exist in domain Y, so that I can accomplish Single Sign On. I think I am missing something, here is my code:
When on domain X and using the below code, it successfully created a cookie with domain set to X and path to /
setcookie('ssisid', $authentication['session']['session_id'], time() + 3600, '/');
When I tried going to domain Y, the cookie was not set.
When I tried adding in domain Y to the code:
setcookie('ssisid', $authentication['session']['session_id'], time() + 3600, '/', 'http://www.example.com');
where example.com is placeholder for my site, no cookie was created on either domain.
What am I missing?
Upvotes: 1
Views: 448
Reputation: 3091
I figured it out. My first code with just the path was correct. The issue was that I was in the Chrome incognito mode. I knew that and I had assumed that all tabs in incognito mode would be part of the same session and be able to pass cookies, but I guess not.
Upvotes: 2