You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Kenneth Lee <ke...@alfacomtech.com> on 2000/07/24 15:23:39 UTC

Apache::Session - can't undef %session?

Hi all,

I found that if I explicitly undef %session, CLEAR will be triggered 
before DESTROY clearing $self->{data}, so $self->save actually update 
nothing in the database.

  # Apache/Session.pm
  ...
  sub CLEAR {
    warn "CLEAR!\n";
  ...
  sub DESTROY {
    warn "DESTROY!\n";
  ...

  # The script
  ...
  tie %session, 'Apache::Session::Oracle', undef, {
    ...,
    Commit => 1,
  };
  $session{array_ref} = [ 1..10 ];
  print "Storing session to database...\n";
  undef %session;  # Nothing stored

When executed, it gives

  bash$ perl test.pl
  Storing session to database...
  CLEAR!
  DESTROY!

Then I use SQLPlus to find in the database, the record is there, but 
it only contains the serialized form of { _session_id => xxx }, which is 
inserted by tie().

Can anyone explain this to me?

Thanks,
Kenneth

Re: Apache::Session - can't undef %session?

Posted by Perrin Harkins <pe...@primenet.com>.
On Mon, 24 Jul 2000, Kenneth Lee wrote:
> I found that if I explicitly undef %session, CLEAR will be triggered 
> before DESTROY clearing $self->{data}, so $self->save actually update 
> nothing in the database.

The perltie page says that this will happen when assigning the empty list
to a tied hash, and apparently it happens when you undef as well.  Maybe
you want to call DESTROY or untie instead.

- Perrin