Adi wrote:
> 
> Andrew Mayo wrote:
> >
> > We are trying to store references in session variables but for some reason
> > this does not work. The reference cannot be regained.
> >
> > For example, in simple Perl I can create an array containing two anonymous
> > hashes, then place a reference to this array in
> > $d, then dereference $d to recover the array.
> >
> > @c[0]={'k1','v1','k2','v2'};
> > @c[1]={'k3','v3','k4','v4'};
> > $d=\@c;
> > print $$d[0]{'k1'},"\n";
> > @e=@$d;
> > print $e[0]{'k1'},"\n";
> 
> The Apache::ASP $Session object is tied to a SDBM_File or DB_File via MLDBM
> Data::Dumper.  Therefore you cannot simply store a reference using "\@c" and
> expect it to dereference next time.  Use an anonymous array [] or anonymous
> hash {}.
> 
> Try this:
> 
> @c[0]={'k1','v1','k2','v2'};
> @c[1]={'k3','v3','k4','v4'};
> $Session->{'array'} = [ @c ];
> print $Session->{'array'}->[0]->{'k1'},"\n";
> @e = @{$Session->{'array'}};
> print $e[0]{'k1'},"\n";
> 
> DBI handles should be storable also, just be sure to use anonymous hash
> syntax, since they are blessed hashes.
> ...

Thanks for answering this Adi.  Andrew, in general, 
read up in Apache::ASP docs & perldoc MLDBM for 
how $Session & $Application are limited when storing data.

To clarify, DBI handles are not storable in $Session, 
because they often have per process file handles & such which 
will not be preserved across requests.  Use Apache::DBI to 
keep your database connections persistent per process.

-- Joshua
_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks >> free web link monitoring   Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

Reply via email to