You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mark Korey <ml...@korey.net> on 2002/06/10 05:43:05 UTC
Porting to mod_perl and cookies are breaking. Why?
Hi,
We're in the process of setting up mod_perl on a site which uses cookies
to perform user authentication. Everything worked fine before mod_perl,
but now the cookie is not set when we check for it.
I've searched the web & "Developer's Cookbook", but can't find any
references
to this type of problem, so I'm turning here!
We have not tried Apache::Cookie yet, I'm hoping that, while it might be
a good solution, it won't be *required*.
Here's what we got:
Embedded Perl version 5.00503 for Apache/1.3.9 (Unix) mod_perl/1.27
and in httpd.conf:
PerlRequire /opt/apache/FSE/share/cgi-bin/start-up.pl
PerlFreshRestart On
Alias /home/ /opt/apache/FSE/share/cgi-bin/
<Location /home/home.cgi>
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
PerlSendHeader On
</Location>
*Why* are cookies not readable?
*How* do we get them working??
ENV{HTTP_COOKIE} does not contain a newly set cookie, often it
still contains an old value when I try to change it (ie switch to a
different user).
Everything else appears to be working fine.
Thanks!
-----------------------------------------------------------
mlk @ korey.net
www.fantasycup.com
-----------------------------------------------------------
Re: Porting to mod_perl and cookies are breaking. Why?
Posted by Per Einar Ellefsen <pe...@skynet.be>.
At 23:55 10.06.2002, Mark Korey wrote:
>We found the problem ... this was an odd one (aren't most!?!).
>Turns out that the path (i.e. $cgi->cookie(-path =>'/', ...); )
>was NOT being set. Guess we assumed that CGI.pm would default it to '/'.
>Setting that seemed to do the trick.
>We are using CGI.pm and did not need to "PerlSetupEnv On".
It's the default to have it On, that's why it got me wondering.
>I'm still not sure why this works differently under mod_perl.
Probably not mod_perl's fault at all, you might have been using a different
path before (or maybe a different vresion of CGI.pm?)
>Semi-related to this, isn't $cgi->cookie just an API which
>uses $ENV{HTTP_COOKIE}?
CGI.pm has mod_perl-related code under the hood. I'm not sure if the same
applies to CGI::Cookie (which is used for $cgi->cookie).
>What's the big advantage of Apache::Cookie?
It's C, so it's faster. It uses the Apache API. You won't have to do things
like print $cgi->header(-cookie => ...), you just do $cookie->bake; But
basically, you don't need it yet.
>I'd like to keep my code as flexible & compatible as possible
>so it will run under both standard CGI & mod_perl, at least
>while we work the kinks out of our mod_perl configuration.
In that case, just keep your current code. You'll only have the use for the
likes of Apache::Cookie when you start moving to the Apache Perl API anyway.
>On Mon, 10 Jun 2002, Per Einar Ellefsen wrote:
>
> > At 05:43 10.06.2002, Mark Korey wrote:
> > >ENV{HTTP_COOKIE} does not contain a newly set cookie, often it
> > >still contains an old value when I try to change it (ie switch to a
> > >different user).
> > >Everything else appears to be working fine.
> >
> > If you're saying that $ENV{HTTP_COOKIE} is empty, you should set
> > "PerlSetupEnv On" in your Location section. See
> > http://perl.apache.org/release/docs/1.0/guide/config.html#PerlSetupEnv
> >
> > Could we see your code (an excerpt showing the problem)? You might be doing
> > something wrong when trying to set cookies. Furthermore, you should really
> > be using CGI.pm, CGI::Cookie or Apache::Cookie for your cookie needs.
--
Per Einar Ellefsen
per.einar@skynet.be
Re: Porting to mod_perl and cookies are breaking. Why?
Posted by Mark Korey <ml...@korey.net>.
We found the problem ... this was an odd one (aren't most!?!).
Turns out that the path (i.e. $cgi->cookie(-path =>'/', ...); )
was NOT being set. Guess we assumed that CGI.pm would default it to '/'.
Setting that seemed to do the trick.
We are using CGI.pm and did not need to "PerlSetupEnv On".
I'm still not sure why this works differently under mod_perl.
Semi-related to this, isn't $cgi->cookie just an API which
uses $ENV{HTTP_COOKIE}?
What's the big advantage of Apache::Cookie?
I'd like to keep my code as flexible & compatible as possible
so it will run under both standard CGI & mod_perl, at least
while we work the kinks out of our mod_perl configuration.
Thanks.
- Mark
www.fantasycup.com
----------------------------------------
On Mon, 10 Jun 2002, Per Einar Ellefsen wrote:
> At 05:43 10.06.2002, Mark Korey wrote:
> >ENV{HTTP_COOKIE} does not contain a newly set cookie, often it
> >still contains an old value when I try to change it (ie switch to a
> >different user).
> >Everything else appears to be working fine.
>
> If you're saying that $ENV{HTTP_COOKIE} is empty, you should set
> "PerlSetupEnv On" in your Location section. See
> http://perl.apache.org/release/docs/1.0/guide/config.html#PerlSetupEnv
>
> Could we see your code (an excerpt showing the problem)? You might be doing
> something wrong when trying to set cookies. Furthermore, you should really
> be using CGI.pm, CGI::Cookie or Apache::Cookie for your cookie needs.
>
>
> --
> Per Einar Ellefsen
> per.einar@skynet.be
Re: Porting to mod_perl and cookies are breaking. Why?
Posted by Per Einar Ellefsen <pe...@skynet.be>.
At 05:43 10.06.2002, Mark Korey wrote:
>ENV{HTTP_COOKIE} does not contain a newly set cookie, often it
>still contains an old value when I try to change it (ie switch to a
>different user).
>Everything else appears to be working fine.
If you're saying that $ENV{HTTP_COOKIE} is empty, you should set
"PerlSetupEnv On" in your Location section. See
http://perl.apache.org/release/docs/1.0/guide/config.html#PerlSetupEnv
Could we see your code (an excerpt showing the problem)? You might be doing
something wrong when trying to set cookies. Furthermore, you should really
be using CGI.pm, CGI::Cookie or Apache::Cookie for your cookie needs.
--
Per Einar Ellefsen
per.einar@skynet.be