|Syntactic Confectionery Delight|
Unable to set cookies for specific domainby bradcathey (Prior)
|on Mar 23, 2009 at 15:12 UTC||Need Help??|
bradcathey has asked for the
wisdom of the Perl Monks concerning the following question:
I have a CMS that users must log into. Besides the login, there are several modules, used for various tasks, that check for the existence of the login when they are invoked.
Some users are reporting being forced to log in twice, once at the first login screen, and a second time after a requested module is invoked.
After hours of testing I finally realized that if a user does not use www. in the URI, the browser was ignoring the 1st cookie set at login, and necessitating a 2nd cookie to proceed.
So, the user enters: domainname.com/admin, but after failing, the browser fills in the address with the full URI as http://www.domainname.com and all is fine. The cookies are showing:
The code to create the cookie was:
So I thought I'd add the domain to the cookie params:
Still no dice. The docs for CGI::Cookie say that the dot form of the domain param, e.g., -domain => .domainname should work for any form of the domain name.
QUESTION: how do I set a proper cookie, irregardless of what the user enters as a starting URI?
Resolved: I set the <base href /> tag in the login tmpl file via $template->param(basehref => $http_post);. The cookie wrote correctly and all is well.
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot