the squares are because your cookie is serialized -- thats just the data structure
Below is a bunch of stuff that i routinely use in a class that is essentially a WebPageVisitor
(its not the complete stuff, so it might seem spotty)
maybe that will help you
---
our $CookieDefaults =
{
domain => [
'127.0.0.1',
],
path => '/',
expires => '+365d',
secure => 0,
};
my $cookiejar = Apache::Cookie::Jar->new( $this->{'ApacheRequestRec'} );
my @names = $cookiejar->cookies();
if ( $cookiejar->cookies('SESSION_ID') )
{
$sessionID = $this->session__validate( $cookiejar->cookies('SESSION_ID')->value );
}
sub session__validate { my $this = $_[0]; my $sessionID = $_[1]; # If not 32 chars long, kill it if ( length($sessionID) != 32 ) { $sessionID = undef; }
# If its not in a valid file, kill it
if ( defined($sessionID) )
{
my $DIR = "${$this->{'ApacheSessionOptions'}}->{Directory}/$sessionID";
if ( -e "${$this->{'ApacheSessionOptions'}}->{Directory}/$sessionID" ) {
}
else
{
$sessionID = undef;
}
}
return $sessionID;
}
sub session__load { my $this = $_[0]; my $sessionID = $_[1]; $this->session__tie( $sessionID ); }
sub session__new { my $this = $_[0]; $this->session__tie( '' ); $this->cookie__session__set(); return $this->{'sessionID'} }
sub session__tie { my $this = $_[0]; my $sessionID = $_[1];
tie %{$this->{'__SESSION'}} , 'Apache::Session::File', $sessionID, ${$this->{'ApacheSessionOptions'}};
$this->{'sessionID'} = $this->{'__SESSION'}{_session_id};
}
sub session__new__if_no_cookie { my $this = $_[0]; my $cookiejar = $_[1]; if ( !$this->login_from_cookie( $cookiejar ) ) { $this->cookie__autologin__kill(); } $this->session__new(); }
sub cookie__session__set
{
my $this = $_[0];
foreach $DOMAIN (@{${$this->{'CookieDefaults'}}->{'domain'}})
{
my $session_cookie = Apache::Cookie->new (
$this->{'ApacheRequestRec'},
-name => 'SESSION_ID',
-value => $this->{'sessionID'},
-domain => $DOMAIN,
-path => ${$this->{'CookieDefaults'}}->{'path'},
-expires => ${$this->{'CookieDefaults'}}->{'expires'},
-secure => ${$this->{'CookieDefaults'}}->{'secure'},
);
# Bake it!
# $session_cookie->bake();
$this->{'ApacheRequestRec'}->err_headers_out->add('Set-Cookie' => $session_cookie);
}
}