This is slightly OT, but I�ve been looking at this now for a day and a half
and seem to be getting no where fast, I was hoping someone could give me a
clue.

I have a simple taglib that stores/retrives a cookie. Simple eh, but try as
I might I cant get the cookie to stick, that is placed in the httpd header.
I�ve tried a million combinations though a hack Joerg Walter�s session
plugin has got me furthest, (Apologies for making a mess of your fine code
Joerg!).

I hope I�m being dumb here and my use of TaglibHelper is not the problem.

The relevant xsp is;

<?xml version="1.0"?>
<?xml-stylesheet href="." type="application/x-xsp"?>
<?xml-stylesheet href="cookie.xsl" type="text/xsl"?>

<xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core";
    xmlns:testlib="http://www.freeloader.com/xsp/test/";
    language="Perl">

<cookie><testlib:chocChip key='alpha' /></cookie>

</xsp:page>

The taglib itself contains the following functions;

sub chocChip()
    {
    my $r = Apache->request();
    my $cookies = $r->pnotes('COOKIES');
    if ($cookies)
        {
        return "got = " . $cookies->{'freeloader'};
        }
    else
        {
        return "sent = " . hack_cookie(value=>'foo', name=>'freeloader',
expires=>'+1d');
        }
    }

sub hack_cookie {
    my (%settings) = @_;
    my $r = Apache->request();
    my ($auth_name, $auth_type) = ($r->auth_name, $r->auth_type);

    $settings{path} ||= '/';
    $settings{domain} ||= $r->hostname;
    $settings{expires} ||= '+1d';

    my $cookie = Apache::Cookie->new($r, %settings);
    $cookie->bake;

    return $cookie->as_string;
}

Reply via email to