reasonablekeith has asked for the wisdom of the Perl Monks concerning the following question:
Monks, I'm banging my head against the wall here. I just can't seem to set a cookie.
I'm using the following set up.
Within the httpd conf I've defined the following, to pick up any dynamic requests...Apache/2.0.54 (Win32) mod_perl/2.0.1 Perl/v5.8.7
I've got my own handler here because I'm picking up the the uri, and using it to run template toolkit against an appropriate file. This goes something like this (a bit cut down)...<Files ~ ".*"> SetHandler perl-script PerlHandler MyOrg::Apache::User PerlSendHeader On Options ExecCGI </Files>
... with $nav being a pre-created object which looks after which uri's compile which templates (although, all this works nicely, so only provided here for context).sub handler { my $r = shift; # use the path_info to determine which template file to process my $file = $r->unparsed_uri; # validate the url as a content page my $tt_path = $nav->get_path_attribute("/$file", 'local_path'); $tt_path =~ s[^/][]; return -1 if ! $tt_path; # Decline this request if the path isn't +in the nav # set up and call the template my $template = Template->new({ PLUGIN_BASE => 'MyOrg::Template::Plugin', INCLUDE_PATH => "$websrc:$websrc\\lib", PRE_PROCESS => 'config', OUTPUT => $r, # direct output to Apache request }); my $params = { uri => $r->uri, navigation => $nav, }; $r->content_type('text/html'); $r->headers_out->add('Set-Cookie' => "CGISESSID=PLEASEWORK; path=/ +"); $template->process($tt_path, $params) || return fail($r, 500, $template->error()); ## 500 -> SERVER_ +ERROR return 0; # OK }
I've tried all sorts of things within this sub, but have settled on showing the simplest example of what, as far as I can understand, should work, but doesn't. Namely, it's that "headers_out" line. It doesn't set a cookie in my browser. I've set my browser to prompt me on and new cookie request, which is popping up new windows all the time, except when I visit my site. Any ideas where I'm going wrong anyone?
All help gratefully received. Thanks, Rob
---
my name's not Keith, and I'm not reasonable.
my name's not Keith, and I'm not reasonable.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Cookies, mod_perl and apache request handlers
by derby (Abbot) on Sep 25, 2007 at 11:46 UTC | |
by reasonablekeith (Deacon) on Sep 25, 2007 at 14:06 UTC | |
Re: Cookies, mod_perl and apache request handlers
by mwah (Hermit) on Sep 25, 2007 at 12:22 UTC | |
Re: Cookies, mod_perl and apache request handlers
by perrin (Chancellor) on Sep 25, 2007 at 10:47 UTC | |
by reasonablekeith (Deacon) on Sep 25, 2007 at 11:00 UTC | |
by perrin (Chancellor) on Sep 25, 2007 at 13:39 UTC | |
Re: Cookies, mod_perl and apache request handlers
by shmem (Chancellor) on Sep 25, 2007 at 11:50 UTC |
Back to
Seekers of Perl Wisdom