Marc, You will need to get the cookie sent back to the browser, if you redirect to a URL with no domain in it - Apache "cleverly" notices this and performs the second request without going back to the browser. To force return to the browser include the domain in the URL $r->headers_out->set( Location => "http://my.dn.org/login?redirect=1" );
On Sun, 14 Aug 2005, Marc Lambrichs wrote: > I'm trying to build a mp2 handler to login using mod_auth_tkt2. I like the > idea of probing if > the client can support cookies, so tried to rebuild it. According to the cgi > example there > is some problem with setting the cookie on a redirect. The same problem - no > probe cookie is set > during the redirect - occurs when I use the following method, and I can't see > why. > > #------------------------------------------------------------------------- > sub login: method > #------------------------------------------------------------------------- > { > my ( $class, $r ) = @_; > > #$r->print('sub run ', B::Deparse->new->coderef2text( \&run )); > my $apr = Apache2::Request->new($r); > > ### Check if there are any cookies defined > my $jar = Apache2::Cookie::Jar->new( $r ); > my $cookie = $jar->cookies( 'tkt' ); > my $probe = $jar->cookies( 'probe' ); > my $has_cookies = $cookie || > $probe || ''; > if ( ! $has_cookies ){ > ### if this is a self redirect warn the user about cookie support > if ( $apr->param( 'redirect' ) ) { > my @remarks = ( 'Your browser does not appear to support cookies.', > 'This site requires cookies - please turn cookie > support' ); > my $detail = join '&', map { sprintf "detail=%s", $_ } @remarks; > $r->internal_redirect_handler( "/error?type=400&$detail" ); > return Apache2::Const::OK; > } > ### If no cookies and not a redirect, redirect to self to test cookies. > else { > $cookie = Apache2::Cookie->new( $r, > -name => "probe", > -domain => 'my.domain', > -value => 1 ); > $cookie->path("/"); > $cookie->bake( $r ); > $r->headers_out->set( Location => "/login?redirect=1" ); > > return Apache2::Const::REDIRECT; > } > } > } > >