du hast scheinbar keine Sessionverwaltung in deinem Script.
such mal unter http://search.cpan.org/ nach "Session"Ein Session-Modul stellt dir eine "magische" Hashreferenz zur Verfügung, in der du Variablen ablegen kannst
Empfehlung: Apache::Session
wenn du unter mod_perl arbeitest, unter CGI das folgende Modul:
package MySession;use Apache::Session::File;
use CGI;
our @EXPORT=qw(initSession);
BEGIN {
mkdir '/tmp/sessions';
mkdir '/tmp/sessionLock';
}
sub initSession {
my $Session = shift;
warn "initSession starts\n";
my $cookie;
if ($id = CGI::cookie('SessionID')) { # schon gesendet
eval {
warn "tie($id) in $$\n";
tie %$Session, 'Apache::Session::File', $id, {
Directory => '/tmp/sessions',
LockDirectory => '/tmp/sessionLock',
};
warn "tie($id) done in $$\n";
};
if ($@) {
warn "Oops: $@\n";
tie %$Session, 'Apache::Session::File', undef, {
Directory => '/tmp/sessions',
LockDirectory => '/tmp/sessionLock',
};
$cookie = CGI::cookie(
-name=>'SessionID',
-value=> $Session->{_session_id},
-expires=>'+12M',
);
return $cookie;
}
} else { # erster kontakt
warn "first tie(undef) in $$\n";
tie %$Session, 'Apache::Session::File', undef, {
Directory => '/tmp/sessions',
LockDirectory => '/tmp/sessionLock',
};
warn "first tie($Session->{_session_id}) done in $$\n";
$cookie = CGI::cookie(
-name=>'SessionID',
-value=> $Session->{_session_id},
-expires=>'+12M',
);
return $cookie;
}
return undef;
}
1;
-----------------------------------------------
im CGI-script dann:
my %Session;
my $cookie = initSession(\%Session);
...
if ($cookie) {
print $q->header(-type => 'text/html',
-content_length => length($txt),
-cookie => $cookie,
);
} else {
print $q->header(-type => 'text/html',
-content_length => length($txt),
);
}
Datum: 20.07.2005-22:19
