Using Apache::Session for storing form data as opposed to database columns

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I realize that searching for data this way is not as efficient, but it
makes it easy if a form changes, there is no need to change a database
structure.  I was wondering if others do it this way, saving all of
their web form data to a hash and putting it in Apache::Session to call
out later with the session id number.  It's like leaving your clothes
at the dry cleaners and taking a ticket home to retrieve the clothes at
a later time.

Here is a sub I wrote to handle the work:

sub session_handler
my ($dbh,$hash_ref,$sess_id_ref,$action) = @_;
my %session;
tie %session, 'Apache::Session::MySQL', $$sess_id_ref,
{Handle=>$dbh, LockHandle=>$dbh};
$$sess_id_ref = $session;
if ($action =~ /write/i)
= $ for keys %}
elsif ($action =~ /read/i)
= $session for keys %session}
elsif ($action =~ /delete/i)

the hash referenced by $hash_ref is either filled with data or is to be
filled with data depending on the value of $action.  Same with

It is tested and appears to work fine.  I started with a big mess of
code and tried to clean it up by using statement modifiers.

Any advice on code would be appreciated and on the soundness of the
overall method of using Apache::Session for storing fairly large
amounts of important data from html forms.



Site Timeline