powerhouse has asked for the wisdom of the Perl Monks concerning the following question:

I have my script place a cookie, that only holds a session id,
cookie (-name => "session_id", -value => $sess_ref->session_id(), -path => url (-absolute => 1), -expires => "+1y" );
However, if I load the site, without loading the script NAME, like this:
http://www.mydomain.com
instead of like this:
http://www.mydomain.com/index.cgi
Then it does not get the cookie, I assume it's because of the url(-absolute=>1) but don't know for sure, I've tried changing that, but then it never recognizes the cookie, what am I doing wrong? Can you see my mistake?

thx,
Richard

Replies are listed 'Best First'.
Re: CGI Cookies...
by dws (Chancellor) on Mar 14, 2003 at 06:34 UTC
    Can you see my mistake?

    No, but I can suggest a debugging technique. Write a small script that dumps %ENV, and look for what's different between the trailing '/' and the no trailing '/' case.

Re: CGI Cookies...
by powerhouse (Friar) on Mar 14, 2003 at 07:13 UTC
    Ahh, I found it...

    cookie (-name => "session_id", -value => $sess_ref->session_id(), #-path => url (-absolute => 1), completely Removed this -domain => ".domain.com", -expires => "+1y" );


    Before I had just kept modifying the -path, this time I removed the whole line, and it worked.

    thx,
    Richard

      Set your path to '/', I say this because i've often had probs with Netscape 4 not setting the cookie if there wasn't a path at all.

      I've also had problems with the evil browser from redmond refusing to set cookies when I don't specify the entire domain. (i.e. leaving off the www) I get around this by setting domain to $ENV{HTTP_HOST}

      Hope that helps
      Chris

      Lobster Aliens Are attacking the world!