in reply to Re^3: Storying a Hash inside a CGI::Session Param?
in thread Storing a Hash inside a CGI::Session Param?

The only thing I've found in the docs, under that section, is dereferencing a reference to an array. I've tried doing something similar to dereference the hash, but not getting much luck with it.

The param is returning the contents of the hash, but not acting like it once it's retrieved.

my $access = $session->param("access"); where the contents of the param 'access' is a hash containing a hash. The contents are correct, when using Data::Dumper, but it's not treating it like a hash. Seems more to be treating it like a string.

print Dumper($access);
returns:
$VAR1 = { 'main' => { 'access' => 1 }, 'server1' => { '1' => { 'siteName1' => 12 }, '10' => { 'siteName2' => 12 } } };

which is the correct structure of the hash (and hashes within it, etc.)


Stenyj
  • Comment on Re^4: Storying a Hash inside a CGI::Session Param?

Replies are listed 'Best First'.
Re^5: Storying a Hash inside a CGI::Session Param?
by beable (Friar) on Jul 04, 2004 at 03:35 UTC

    Ok try this:

    # store a reference to the hash # note the backslash! $session->param("access", \%access);

    Now to retrieve your data:

    #retrieve the reference to the hash my $access_ref = $session->param("access");

    Once you have the reference to the hash back, you can use it to access the data:

    # access the data in the hash reference print "My data from the hash is: ", $access_ref->{hashkey}, "\n";

    Replace "hashkey" above with an actual hash key. See if that works for you.