how do I store/retrieve a hash through Apache::Session?
Maybe a silly question... how do I store/retrieve a hash through Apache::Session? This doesn't work... # retrieve %table=$session{table}; ... # store $session{table}=%table; What's my fault?
Re: how do I store/retrieve a hash through Apache::Session?
* Enrique I.Rodriguez ([EMAIL PROTECTED]) [001103 12:41]: Maybe a silly question... how do I store/retrieve a hash through Apache::Session? This doesn't work... # retrieve %table=$session{table}; ... # store $session{table}=%table; What's my fault? You can only store/read references: my %table = (this = 'that' ); $session{table} = \%table; ... my $table = $session{table}; foreach my $key ( keys %{ $table } ) { print "$key = $table-{ $key }\n"; } see 'perldoc perlref' for much more on references. HTH Chris -- Chris Winters Senior Internet Developerintes.net [EMAIL PROTECTED] http://www.intes.net/ Integrated hardware/software solutions to make the Internet work for you.
Re: how do I store/retrieve a hash through Apache::Session?
On Fri, 3 Nov 2000, Enrique I.Rodriguez wrote: Maybe a silly question... how do I store/retrieve a hash through Apache::Session? store hash references, not hashes. This doesn't work... # retrieve %table=$session{table}; $tableref = $session{table}; ... # store $session{table}=%table; $session{table}= \%table; or, preferably: my $tableref = {}; # add stuff to table # ... $session{table}= $tableref; What's my fault?
Re: how do I store/retrieve a hash through Apache::Session?
Enrique-- You need to store/retrieve it as a ref- \%my_hash Tom At 04:36 PM 11/3/00 +, Enrique I.Rodriguez wrote: Maybe a silly question... how do I store/retrieve a hash through Apache::Session? This doesn't work... # retrieve %table=$session{table}; ... # store $session{table}=%table; What's my fault?
Re: how do I store/retrieve a hash through Apache::Session?
Once you realize that %session entries have to be scalars (references) as described by other responses, be sure when you change entries in the sub-hash that you tell the top-level session that the data's been changed (it won't realize it unless you change one of its scalars). Check the docs or the archives for the "official way" to do this (a message from Jeffrey Baker uses such a phrase), but any modification of a %session scalar will do - $session{_changed}++; , f'rinstance. Best, Randy On Fri, Nov 03, 2000 at 04:36:15PM +, Enrique I . Rodriguez wrote: Maybe a silly question... how do I store/retrieve a hash through Apache::Session? This doesn't work... # retrieve %table=$session{table}; ... # store $session{table}=%table; What's my fault?