Home > Archive > PERL Modules > January 2006 > CGI Cookie Path Question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
CGI Cookie Path Question
|
|
| Daniel Kaplan 2006-01-10, 3:59 am |
| Hello All,
All my cookies are created with the path set to "/" and everything was
working fine. The one and only way I set my cookies was the line below.
And I know I have it only once as I keep it in one of my function modules
and call it with a function call.
$q->redirect(-cookie=>$cookies,-uri=>$new_url);
Everything was peechy keen until I started using fullpaths for the $new_url
value (i.e. http://myserver/cgi-bin/loggedon.pl"). The cookie path stayed
the same, "/", but now I was no longer reading them. Once I went back to
calling my function with $new_url no longer having the path, just
"loggedon.pl", everything went back to normal.
I know changing the path within cookie affect who can and can't read them.
But as well, all my cookies are created through the same function call, and
the path is hardcoded to "/".
So it seems to me, that the path from COOKIE is being ignored, and being
replaced with the path from the URI.
Is anyone familiar with anything like this?
Thanks ahead,
Daniel
| |
| Gunnar Hjalmarsson 2006-01-10, 3:59 am |
| Daniel Kaplan wrote:
> All my cookies are created with the path set to "/" and everything was
> working fine. The one and only way I set my cookies was the line below.
> And I know I have it only once as I keep it in one of my function modules
> and call it with a function call.
>
> $q->redirect(-cookie=>$cookies,-uri=>$new_url);
>
> Everything was peechy keen until I started using fullpaths for the $new_url
> value (i.e. http://myserver/cgi-bin/loggedon.pl").
Are you hardcoding the domain as well? Maybe using something else but
'myserver', e.g. 'www.myserver'?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
| |
| Daniel Kaplan 2006-01-10, 3:59 am |
| "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:41aphrF1dofmrU1@individual.net...
> Are you hardcoding the domain as well? Maybe using something else but
> 'myserver', e.g. 'www.myserver'?
yes.... as long as I just say "NextScript.pl" and not
http://myswerver.com/cgi-bin/NextScript.pl everything is .
Very weird
| |
|
|
| Daniel Kaplan 2006-01-10, 4:00 am |
| "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:41bde1F1dg76vU1@individual.net...
> In that case, try
>
> http://www.myserver.com/cgi-bin/NextScript.pl
>
I'll check it out, though I went and changed it all instances to relative
paths as opposed to absolute.
But am curious as to the cause, since from the documentation (as I read it)
does not mention that the path of the URI in calling redirect affects the
path of the cookie.
| |
| Gunnar Hjalmarsson 2006-01-10, 4:00 am |
| Daniel Kaplan wrote:
> Gunnar Hjalmarsson wrote:
>
> I'll check it out, though I went and changed it all instances to relative
> paths as opposed to absolute.
>
> But am curious as to the cause, since from the documentation (as I read it)
> does not mention that the path of the URI in calling redirect affects the
> path of the cookie.
Let's say you set a cookie via this script:
#!/usr/bin/perl
# setcookie.pl
print "Set-cookie: test=xyz; path=/\n";
print "Content-type: text/plain\n\n";
print "Cookie set for $ENV{HTTP_HOST}\n";
__END__
by invoking it as http://www.myserver.com/cgi-bin/setcookie.pl
Then, if you try to 'read' the cookie via:
#!/usr/bin/perl
# readcookie.pl
print "Content-type: text/plain\n\n";
print "Available cookies: $ENV{HTTP_COOKIE}\n";
__END__
you must invoke the latter as http://www.myserver.com/cgi-bin/readcookie.pl
The browser will _not_ include the cookie in the cookie header if you
invoke readcookie.pl as http://myserver.com/cgi-bin/readcookie.pl
HTH
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
| |
| Gunnar Hjalmarsson 2006-01-10, 4:00 am |
| Daniel Kaplan wrote:
> the documentation (as I read it) does not mention that the path of
> the URI in calling redirect affects the path of the cookie.
If the path is set explicitly, it doesn't. OTOH, the _host_ of the URI
does affect the cookie domain.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
|
|
|
|
|