hmm, I still can't get it to work, but it somehow works under LWP. the following code actually gets the cookie correctly, and no bogus sessions are created in my server. any ideas??
use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new(); $ua->cookie_jar({ file => "$ENV{ HOME }/cookies.txt", autosave => 1 }); my $req = HTTP::Request->new( GET => 'http://foobar.com' ); my $res = $ua->request( $req ); print $res->as_string; print $ua->cookie_jar->as_string, "\n"; --d Daisuke Maki wrote: > I'm really lost with this... > > I'm trying to set a session cookie from PerlAccessHandler. I'm basically > doing (simplified code): > > my $cookie_jar = Apache::Cookie->fetch > my $session_id = $cookie_jar->{ session }->value; > > if( !session_active( $session_id ) ) { > my $session_obj = create_session_obj(); ## create and store new > session > my $cookie = Apache::Cookie->new( > $r, > -name => 'session', > -value => $session_obj->id, > -path => '/', > -domain => 'my.domain.com', > -expires => '+30m' > ); > > $r->headers_out->add( "Set-Cookie" => $cookie->as_string ); > } > return DECLINED; > > This works fine for the first access. Subsequently, I wipe out the > backend database to see if a new session is correctly created. A new > session is created as expected, but the problem is that the new cookie > does not seem to stick to the browser. I've verified that this doesn't > seem to be a browser issue, as I have problems with all browsers that I > have ( IE5.5, IE6, Mozilla 1.0rc) > > Is there any known gotchas for this type of thing? Or am I missing > something? > > TIA, > --d > >