perlquestion
CodeJunkie
<p>Hi,<br/>
I have a CGI cookie domain question for you all.</p>
<p>I have 2 websites, my main site is http://www.mysite.com/ and my new site is http://www.newmysite.com. However newmysite.com is actually hosted at http://www.mysite.com/newmysite/. I have just asked my domain registar to forward to this new location and put in a frame so that it looks like it's own site, but I dont have to buy more dedicated webspace.</p>
<p>On my new website I have a log in page that lets people log into the website, however the domain cookie thing is giving me problems. If I look at the site from:<br/>
http://www.mysite.com/newmysite/ and have cookie dropping code that looks like this:
<code>
sub dropCookie {
my ($username,$form)=@_;
my $sessionID = md5_hex(md5_hex(time.{}.rand().$$));
my $value = "$sessionID\.$username";
my $cookie = $form->cookie(-name=>'sessionID',
-value => $value,
-path=>'/',
-domain=>'.mysite.com');
print $form->header(-cookie=>$cookie) or &dieNice("Failed to put cookie on users computer");
return;
}
</code>
<p>It works fine, but I can't login when I go to www.mynewsite.com. I think this is because the domain is specified at .mysite.com as opposed to .newmysite.com. But it still doesn't work when I change the code to domain=>'.newmysite.com'.</p>
<p>I hope that all makes sense to everyone, it's not really that complicated, but I'm not sure I've explained it too well</p>
<p>Many thanks,<br/>
Tom</p>