> 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
...
> Is there any known gotchas for this type of thing? Or am I missing
> something?

Could this be a redirection problem? One gotcha that I learned was that:
my $method = ($is_redirection) ? 'err_headers_out' : 'headers_out';
$r->$method->add("Set-Cookie" => $cookie->as_string);


I don't know if this is similar to what I did, but here you go anyhow:

sub hash_to_cookies {
    my ($r, $hashref) = @_;
    my $is_redirection = (@_) ? shift : undef;
    my $method = ($is_redirection) ? 'err_headers_out' : 'headers_out';
    # From Apache::Cookie documentation:
    # $cookie->bake is same as $r->err_headers_out->add("Set-Cookie" =>
$cookie->as_string);
    # Guide: You should use err_headers_out() and not headers_out()
    # when you want to send cookies in the REDIRECT response.
    my ($cookie);
    foreach my $key (keys %{$hashref}) {
        $cookie = Apache::Cookie->new(  $r,
                                        -name   => $key,
                                        -value  => $hashref->{$key},
                                        -path   => '/');
        $r->$method->add("Set-Cookie" => $cookie->as_string);
    }
}
sub hash_to_cookies_OK {hash_to_cookies(@_);}
sub hash_to_cookies_REDIRECT {hash_to_cookies(@_, 1);}


-- 

Kari Nurmela,
        [EMAIL PROTECTED], (02) 333 8847 / (0400) 786 547

Reply via email to