Hello; I'm having some curious problems with sessions in my scripts. I am using the Apache::Session::Postgres module. Mod_Perl 2 on Apache 2, on Debian (Lenny). Sessions are being tracked using cookies.
I am setting session data using code of the following form: 73 my $r = Apache2::RequestUtil->request; 74 my %session; 76 tie %session, 'Apache::Session::Postgres', undef, { 77 DataSource => 'dbi:Pg:dbname=database;host=localhost', 80 UserName => 'username', 81 Password => 'password', 82 TableName => 'web.session', 83 Commit => 1 84 }; 87 my $session_cookie = "SID=$session{_session_id};"; 88 $r->headers_out->add('Set-Cookie' => $session_cookie); 89 $session{some_key} = $some_variable; 90 95 untie(%session); 96 undef %session; Now, this seems to be inserting the correct value into the session, and is saving it properly in the database (checked by decoding the a_session data straight from the database). The problems seem to be happening when I go to retrieve this data - I am intermittently getting the incorrect data back. For example, let user A have a session associated with him. He has the string 'cow' in $session{animal}. User B, meanwhile, has 'goose' in $session{animal}. Now, intermittently, user A is getting 'goose' when retrieving $session{animal}. The session variables are being retrieved as follows (in a different script of course): 35 my $r = Apache2::RequestUtil->request; 36 my $cookie = $r->headers_in->{'Cookie'}; 40 local(@rawCookies) = split (/; /,$cookie); 41 local(%cookies); 43 foreach(@rawCookies) 44 { 45 ($key, $val) = split (/=/,$_); 46 $cookies{$key} = $val; 47 } 49 my $id = $cookies{'SID'}; 50 my %session; 54 tie %session, 'Apache::Session::Postgres', $id, 55 { 56 DataSource => 'dbi:Pg:dbname=database;host=localhost', 59 UserName => 'username', 60 Password => 'password', 61 TableName => 'web.session', 62 Commit => 1 63 }; 71 my $some_variable = $session{some_key}; 85 untie(%session); 86 undef %session; Given that these are essentially text-book examples, you can understand why the situation is perplexing me...It is almost as if some variable is persisting between executions of the script that shouldn't be. Any ideas? Sam Ingarfield