Hi,
I have a CGI cookie domain question for you all.

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.

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:
http://www.mysite.com/newmysite/ and have cookie dropping code that looks like this:

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 coo +kie on users computer"); return; }

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'.

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

Many thanks,
Tom


In reply to Having a cookie domain by CodeJunkie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.