my $loop=8;
my $pm = Parallel::ForkManager->new($loop);
my $url = "http://localhost/cgi-bin/session.pl";
my %sessionopts; # must contain same config as apache has
my $sid;
# get sessionID with initial request to session.pl
# ...
for (my $i = 0; $i < $loop; $i++) {
$pm->start and next;
my $wait = int((rand)*3000000);
# pass loop number, random wait time and sessionID in to script
my $content = "count=$i&wait=$wait&sid=$sid";
my $requrl = $url.'?'.$content;
print "sending req $i [$requrl] at ".join(':',gettimeofday)."\n";
my $req = HTTP::Request->new('GET', $requrl);
my $resp2 = $ua->request($req);
$pm->finish;
}
sleep 10; # be sure last req has finished
print "now what is in the session for [$sid]?\n";
my %session;
tie %session, 'Apache::Session::Flex', $sid, {
%sessionopts
};
print "got session data: ".Dumper(\%session)."\n";
####
# ...
# extract cgi args from query string
# open session, either using Apache::SessionManager or Apache::Session directly
# ...
usleep($wait); # wait for a few microseconds to simulate real server doing stuff
$session->{'time'} = join('+',gettimeofday);
$session->{'querystring'} = $query;
$session->{'count'} = $count;
my $now = time();
$session->{"$now:$count"} = $count;
warn "got session ".Dumper($session);
####
now what is in the session for [8f13e7d0f1d140f6a1100510c1f82f6a]?
got session data: $VAR1 = {
'count' => '6',
'1098930095:0' => '0',
'time' => '1098930095+468658',
'_session_start' => 1098930095,
'1098930095:6' => '6',
'1098930095:3' => '3',
'_session_id' => '8f13e7d0f1d140f6a1100510c1f82f6a',
'current_uri' => '/cgi-bin/session.pl',
'querystring' => 'count=6&wait=173631&sid=8f13e7d0f1d140f6a1100510c1f8
2f6a',
'previous_uri' => '/cgi-bin/session.pl'
};