Hi Raymond Thanks. I didn't know about Apache2::Cookie. Using the bake method and $m->redirect I get an HTTP header of 302 not 301 that I was getting before when I set the Set-Cookie header manually and then called $m->redirect. Don't quite understand why (perhaps bake() sets the HTTP response code?). But it all works nicely now.
Thanks all Justin (aka Kroptokin) ----- Original Message ----- From: "Raymond Wan" <[EMAIL PROTECTED]> To: "kropotkin" <[EMAIL PROTECTED]> Cc: <mason-users@lists.sourceforge.net> Sent: Monday, September 29, 2008 12:48 PM Subject: Re: [Mason] Headers problem and redirect > > Hi Kropotkin, > > > kropotkin wrote: >> Hi I am using the following: Apache 2.0.52. mod_perl 2.0.3 and Mason >> 1.69.I >> am trying to set a cookie and do a full http re-direct, in the same >> breath >> (so to speak). I have this:$r->headers_out->set('Set-Cookie: ' => >> $testCookie);$m->redirect($location);The Set-Cookie header is not sent.If >> I >> do this:$r->headers_out->set('Set-Cookie' => >> $testCookie);$r->headers_out->set('Location' => >> $location);$m->abort(301);the same problem.What I want to do is send a >> set >> cookie header and do a redirect. At $location I then check for the cookie >> and I can see if the client is accepting cookies. But the sending of the >> redirect (especially the abort) stops Apache sening the Set-Cookie >> header. >> Any help gratefully appreciated..Kropotkin >> > > I also do redirects and set cookies, but i do it differently. Does > altering the following fit your needs? > > ----- > use Apache2::Request (); > use Apache2::RequestRec (); > use Apache2::Const -compile => qw(OK); > > my $cookie = Apache2::Cookie->new ($r, > -name => 'testcookie', > -value => 'foo', > -expires => '+1h', > -path => '/', > -domain => 'your.domain.here' > ); > > $cookie -> bake ($r); > > > $m -> redirect ($somewhere); > ----- > > You might want to reduce the arguments to "new" to the minimum as a > starting point...i.e., just name and value. > > Good luck! > > Ray > > PS: This is not exactly what I have...I cut and pasted from various parts > in my code... > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users