I encountered a weird problem while writing a
simple authentication handler (based on TicketTool from the eagle book again :
).
My virtual host was setup as
follows...
<VirtualHost 192.168.100.2>
DocumentRoot /usr/local/apache/htdocs ServerName mydomain ...
</VirtualHost>
In my authentication handler I tried setting a
cookie with a command like this:
$r->err_headers_out->add('Set-Cookie' =>
"easy=123; domain=mydomain");
However, Apache would not send the cookie to
the server. When I removed the "domain" setting from the cookie, it
worked, and sent over a cookie with domain "mydomain" which is exactly what I
was trying to achieve when explicitly setting the domain. Why wouldn't
Apache send my original cookie?
After some more testing, I realized that setting my
VirtualHost up with a fully qualified ServerName also solves the problem.
In other words, changing the virtual host to this:
...
</VirtualHost>
...allows me to set the domain in my cookie (e.g. "domain=mydomain.com")
and have it sent. Checking the Apache documentation, I found that the
syntax for ServerName requires it to be fully qualified. However, not
using a fully qualified domain name seems to work for other purposes, and I
can't figure out the reason for a conflict with cookies. I know it's not
going to get the lost hair back on my head, but I'd still like to understand
what's going on.
Thanks,
Will
|