Member Rara Avis
... is there no way then to cover both eventualities?
Actually, there is, at least two that I know (now).
Click on the above link and then look at your Address/Location bar. This is the result of an Apache configuration command (see RedirectPermanent ) placed in httpd.conf on the server. It is activated way before any page or Perl code can be called, making it impossible to create cookies for the base domain … 'cause ya can't get there from here (or any where else).
The benefits to this solution go well beyond cookies. Most of the search engines, and especially Google, count links to your web site as "votes" from outside parties. If you have 1,000 links to your site and I have only 500 to mine, Google figures your site is "better" than my site. All other things being equal (though they never are), your site will rank much higher in a search than will mine. The problem arises when your 1,000 inbound links are split and my 500 aren't. You have 500 links to domain.com, 500 links to www.domain..com, thus making each equivalent to my 500 links. Your "votes" have been diluted by inconsistent linking, so you don't get all the benefits from them that you could.
When Google encounters a RedirectPermanent (often called a 301), it realizes the two domains should be considered the same and combines all their votes.
The disadvantage to this solution is that it's pretty low level and won't be available to everyone. If you're on a shared server, the only way to implement it is to talk your hosting company into making the changes for you. Frankly, most hosting companies won't know enough about Apache to even know what you want.
So, here's an alternative solution that should work for you. I haven't tested it, so would appreciate your feedback on the results.
Change every instance of this:
print qq~Set-Cookie: egowhores=$value;expires=$Expires;path=/;\n~;
print qq~Set-Cookie: egowhores=$value;expires=$Expires;domain=. egowhores.com;path=/;\n~;
Please note that .egowhores.com has TWO periods, and could probably be read as *.egowhores.com to be more intuitive. This "should" make your cookies work across all subdomains, including www. Let me know if it does?