On Fri, Oct 2, 2009 at 2:58 AM, Sam Ingarfield <sjfingarfi...@gmail.com> wrote: > 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}.
This usually means you have a scoping problem in your code, where something that should be cleared is not. > 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; This is pretty strange code: using local(), $key and $val are globals, no safety check to see if you got something in $id or succeeded in the tie() call. I'd turn on strict and warnings and put in a bunch of debug logging and see if you can sort it out. However, the problem may be that you're putting the result of the session read into some other variable that has scoping issues, and not with this code at all. - Perrin