I'm working locally across two "domains". I have enterprise.local and application.local virtual hosts on my machine and I need to set a domain cookie for "local" or ".local" I'm having some trouble getting the cookie to set properly, though. In application.local, I have this:
setcookie( 'iPlanetDirectoryPro', trim( $token_id ), '0', '/', '.local' );
header( 'Location: /adcom-sso' );
I've also tried this:
header( 'Set-Cookie: iPlanetDirectoryPro=' . trim( $token_id ) . '; path=/' );
header( 'Location: /adcom-sso' );
Using setcookie()
, no cookie is ever set. Using the Set-Cookie
header, the cookie is set. I've removed the redirection from both and the result never changes. It works for Set-Cookie
, but not for setcookie()
. That would be fine since I don't really have a preference which solution I use, but in the Set-Cookie
solution, as soon as I add a domain it all breaks down:
header( 'Set-Cookie: iPlanetDirectoryPro=' . trim( $token_id ) . '; path=/; domain=local' );
As soon as I add in the domain value, I get a header error:
Header may not contain more than a single header, new line detected.
I've tried the domain value as "local" and ".local". The behavior doesn't change.
I rarely have to explicitly access cookies, so I hope I'm just missing something obvious, but I surely don't see it. Any insight would be much appreciated.
UPDATE: I think I've narrowed this down a bit further. It seems that both ways will work as long as I don't include a domain value. Could there be a problem with using "local" or ".local" as the specific domain for the cookie?