Hi James,

There are a couple of issues here.  One is that
Apache::Session::DB_File doesn't use MLDBM, so you can't use that to
read it.  It uses DB_File.  The other is that Data::Dumper may not do
what you hope when you hand it a tied variable, i.e. not a real hash.
I'm not certain about that one though.

My advice is to use CGI::Session instead of Apache::Session.  It's
less error-prone and is well-maintained.

- Perrin

On Tue, Apr 3, 2012 at 3:40 PM, James B. Muir
<james.b.m...@hitchcock.org> wrote:
> Hi All,
>
>
>
> I’m using Apache::Session::DB_File to manage some sessions via a mod_perl2
> handler and Apache2. I’m running into difficulties trying to read stored
> data in the sessions db while writing a  cleanup cron job to remove old
> sessions. The following code snippet illustrates the problem:
>
>
>
> use strict;
>
> use warnings;
>
> use Fcntl;
>
>
>
> use MLDBM qw(DB_File Storable);
>
>
>
> use Data::Dumper;
>
>
>
> tie my %sessions, "MLDBM", './sessions.db', O_RDWR|O_CREAT, 0666 or die $!;
>
>
>
> (tied %sessions)->DumpMeth('portable'); # use Storable::nfreeze
>
>
>
> my @keys = map { print "$_\n"; $_; } (keys %sessions);
>
>
>
> print Dumper( \%sessions);
>
>
>
> untie %sessions;
>
>
>
> I am unable to read the stored data when I run the above code. I get the
> following output -- two session keys (OK) and mysterious error message when
> I try to dump out a session:
>
>
>
>>perl cleanup.pl
>
> e7324413d95fe51f1ac7e74a89b17b47
>
> f72ec1ed349c7140e9f37087e04cd703
>
> Not a SCALAR reference at
> /usr/local/lib/perl5/site_perl/5.8.8/MLDBM/Serializer/Storable.pm line 28.
>
>
>
> I inspected both MLDBM and Apache::Session::DB_File and it looks to me like
> they both use Storable::thaw to unserialize the data. Any ideas why I am
> getting this message?
>
>
>
> -James
>
>
>
>
>
>
> IMPORTANT NOTICE REGARDING THIS ELECTRONIC MESSAGE:
>
> This message is intended for the use of the person to whom it is addressed
> and may contain information that is privileged, confidential, and protected
> from disclosure under applicable law. If you are not the intended recipient,
> your use of this message for any purpose is strictly prohibited. If you have
> received this communication in error, please delete the message and notify
> the sender so that we may correct our records.

Reply via email to