hesco has asked for the wisdom of the Perl Monks concerning the following question:

Even changing my call to my ->log() method into a `or die` is not giving me anything illuminating from $!. These tests are being run through the browser. Why, pray tell, is my application unable to update its session with this new data? Would the fact that it is attempting to overwrite data for existing parameters have anything to do with that?

$self->{'s'} isa CGI::Session object.

if(defined($self->{'s'})){ $self->{'s'}->flush() or $self->log( 'WARNING', 'Failed attempt to flush session parameters for _cgisess_' . $self->{'s'}->id() . ' to the file store: ' . $!); }
The session is owned and writable by apache, which created it.

hesco@localhost:~/$ ls -l /tmp/sessions/ . . . -rw-r----- 1 www-data www-data 333 2009-06-30 22:57 /tmp/sessions/cgis +ess_55efa0dbfaa6203e3fc97a50db05c837
Any help is appreciated,
-- Hugh

if( $lal && $lol ) { $life++; }

Replies are listed 'Best First'.
Re: Failed attempt to flush CGI::Session parameters, huh ???
by Anonymous Monk on Jul 01, 2009 at 04:58 UTC
    You're supposed to use CGI::Session->errstr()
Re: Failed attempt to flush CGI::Session parameters, huh ???
by hesco (Deacon) on Jul 01, 2009 at 20:20 UTC
    With all due respect and gratitude to the anonymous monk who responded above, I have now tried the following combinations to ascertain the issue here. None of them have been successful, as of yet. Neither $s->errstr(), nor $s->dump() have much to say for themselves. Only invoking my own handrolled ->log() method seems to give me any output. And the Data::Dumper output of the $self->{'s'} object reveals no error strings hiding in the hash. Any further wisdom available?

    if(defined($self->{'s'})){ # $self->{'s'}->flush() or $self->log('WARNING','Failed attempt to f +lush session parameters for cgisess_' . $self->{'s'}->id() . ' to th +e file store: ' . $!); # $self->{'s'}->flush() or die 'Failed attempt to flush session para +meters for cgisess_' . $self->{'s'}->id() . ' to the file store: ' . + $!; $self->{'s'}->flush() or print STDERR 'Failed attempt to flush sessi +on parameters for cgisess_' . $self->{'s'}->id() . ' to the file sto +re: ' . CGI::Ses sion->errstr(); # $self->{'s'}->flush() or print STDERR 'Failed attempt to flush ses +sion parameters for cgisess_' . $self->{'s'}->id() . ' to the file s +tore: ' . $self->{'s'}->errstr(); } $self->{'s'}->dump(); CGI::Session->dump(); $self->log('DEBUG','Our session in the end reads: ',$self->{'s'});
    if( $lal && $lol ) { $life++; }
      Any further wisdom available?

      Please provide a short self-contained program which replicates your problem. Then, provide all the debug output from that program even if it isn't helpful (please include Dumper output of both CGI and CGI::Session object). Also provide module version information (use Devel::Modlist).

      This is the code for sub flush:

      sub flush { my $self = shift; # Would it be better to die or err if something very basic is wron +g here? # I'm trying to address the DESTORY related warning # from: http://rt.cpan.org/Ticket/Display.html?id=17541 # return unless defined $self; return unless $self->id; # <-- empty session # neither new, nor deleted nor modified return if !defined($self->{_STATUS}) or $self->{_STATUS} == STATUS +_UNSET; if ( $self->_test_status(STATUS_NEW) && $self->_test_status(STATUS +_DELETED) ) { $self->{_DATA} = {}; return $self->_unset_status(STATUS_NEW | STATUS_DELETED); } my $driver = $self->_driver(); my $serializer = $self->_serializer(); if ( $self->_test_status(STATUS_DELETED) ) { defined($driver->remove($self->id)) or return $self->set_error( "flush(): couldn't remove session + data: " . $driver->errstr ); $self->{_DATA} = {}; # <-- removing all + the data, making sure # it won't be acce +ssible after flush() return $self->_unset_status(STATUS_DELETED); } if ( $self->_test_status(STATUS_NEW | STATUS_MODIFIED) ) { my $datastr = $serializer->freeze( $self->dataref ); unless ( defined $datastr ) { return $self->set_error( "flush(): couldn't freeze data: " + . $serializer->errstr ); } defined( $driver->store($self->id, $datastr) ) or return $self->set_error( "flush(): couldn't store datastr: + " . $driver->errstr); $self->_unset_status(STATUS_NEW | STATUS_MODIFIED); } return 1; }
      If all else fails you can copy it into your program and add debug statements
      sub CGI::Session::flush { package CGI::Session; ... warn "so far so good"; ... }