in reply to Re: Storying a Hash inside a CGI::Session Param?
in thread Storing a Hash inside a CGI::Session Param?
Actually, I'm using session so that the user never has the data.
I store the data in the session (which the client can't access/modify) and then reference the session via a cookie stored in the client's browser (which is standard practice, I believe).
I'm trying to set it up so that the session can contain data that will otherwise require me to do a number of different database queries for every single one of my scripts.
It comes down to:
- Either I do it via sessions, if possible
OR
- Every script of mine will have to do a number of db queries every time they're executed.
I'm assuming sessions is a more efficient way of doing it, if I can store the necessary data.
Theoretically I could store it into the session using several dozen params, but for simplicity in the scripting, I was hoping to store it into the session in the form of a hash, so that I don't have to have 20-30 lines of param retrieval for every script. And it would also allow for much simpler coding since a lot of my scripts react differently, based on the data passed to them from the session.
One line making reference to a hash within a hash...
ie.
%access = $session->param("access");
$loggedIn = $access{sports}{soccer};
vs.
taking in the param that was broken into an array, rebuilding the hash from the arrah contents, then doing that line.
is a lot easier to manage, and a lot nicer coding.
I'm assuming, from your response, though that it's not possible to store a param in a manner which it will easily be retrievable as a hash.
I suppose I'll just have to write a subroutine in a library and then call it at the beginning of all of my scripts then.
*sigh*
Thanks for the info. I appreciate the response, even though I'm dissapointed to hear the answer... heh heh. I can dream, can't I? LOL
Stenyj