On Tue, 16 Jan 2001, Todd Finney wrote:

> I'm using Apache::Session::Postgres to track sessions via
> cookies.  When I access a page, the cookie is correctly
> sent by the server, and accepted by the client.  However,
> on the second request, I'm getting a 'Object does not exist
> in data store' error.

Looks like it could be a transaction handling problem.  I'll have a look
tonight. -jwb

>
> It looks like the session is not being stored in the
> database, although I can't figure out why.  When running
> postmaster -d 2, I get the following output:
>
> started: host=localhost user=postgres database=sessions
> InitPostgres
> StartTransactionCommand
> query: begin
> ProcessUtility: begin
> CommitTransactionCommand
> StartTransactionCommand
> query:
>                  INSERT INTO sessions (id, a_session)
> VALUES
> ('8efc89ae6006cfdfa24d12eba4019526','AwMAAAABCiA4ZWZjODlhZTYwMD
> ZjZmRmYTI0ZDEyZWJhNDAxOTUyNlgAAAALX3Nlc3Npb25faWRY
> ')
> ProcessQuery
> CommitTransactionCommand
> StartTransactionCommand
> query: rollback
> ProcessUtility: rollback
> CommitTransactionCommand
> StartTransactionCommand
> query: begin
> ProcessUtility: begin
> CommitTransactionCommand
> StartTransactionCommand
> query:
>                  UPDATE sessions SET a_session =
> 'AwMAAAAAWA==
> ' WHERE id = NULL
> ProcessQuery
> CommitTransactionCommand
> StartTransactionCommand
> query: commit
> ProcessUtility: commit
> CommitTransactionCommand
> StartTransactionCommand
> query: begin
> ProcessUtility: begin
> CommitTransactionCommand
>
> It appears to be rolling back the insert transaction, but I
> don't know why.  The session does not appear in the
> database, and all subsequent requests fail.   I've tried
> undef'ing, untie'ing, and make_modified (and various
> combinations) on the hash, to no avail.
>
> The whole handler is below, in case you're interested.
>
> thanks,
> Todd
>
>
> package LocalSites::Session;
>
> use strict;
> use Apache::Constants qw( DECLINED);
> use Apache::Log;
> use Apache::Session::Postgres;
>
> sub handler {
>      my $r = shift;
>      my $log = $r->server->log();
>      my $session;
>      my $use_cookies = $r->dir_config->{'UseCookies'} || 0;
>
>      if ($use_cookies) {
>          $log->error("Session: Begin Transaction Using
> Cookies");
>          $session = $r->header_in('Cookie');
>          $session =~ s/SESSION_ID=(\w*)/$1/;
>          $log->error("Session: ID is $session");
>      } else {
>          $log->error("Session: Begin Transaction Using Path
> Info");
>          # Placeholder for code to extract SESSION_ID from
> the path
>      }
>      undef $session if ! $session;
>
>      my %session = ();
>      tie %session, 'Apache::Session::Postgres', $session, {
>          DataSource=>'dbi:Pg:dbname=sessions',
>          UserName=>'postgres',
>          Password=>'password',
>          Commit=>1
>          };
>      my $cookie = "SESSION_ID=".%session->{_session_id}.";
> domain=.dom.com; path=/;";
>      $r->header_out("Set-Cookie"=>$cookie ) if ! $session;
>      $r->pnotes('SESSION_ID', %session->{_session_id});
>      $r->pnotes('AUTH_LEVEL', %session->{auth_level} || 0
> );
>      $log->error("Session: ".%session->{_session_id});
>      untie(%session);
>      undef %session;
>      $log->error("Session: End Transaction");
>      return DECLINED;
> }
>
>

Reply via email to