Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

How do I retrieve the value of the parameter "message" submitted via an online form? I'm trying to get the value of "this is the message" through the saved $session object.
$VAR1 = bless( { '_STATUS' => 5, '_OBJECTS' => { 'serializer' => 'CGI: +:Session::Serialize::default', 'driver' => bless( { 'DataColName' => +'a_session', 'Directory' => 'E:/myweb/sessions', 'IdColName' => 'id', + 'TableName' => 'sessions', 'NoFlock' => 0, 'UMask' => 432 }, 'CGI::S +ession::Driver::file' ) }, '_CLAIMED_ID' => '45e0195a202edc839b7ae424 +91f05d43', '_DATA' => { '_SESSION_ETIME' => 7200, '_SESSION_ID' => '4 +5e0195a202edc839b7ae42491f05d43', '_SESSION_REMOTE_ADDR' => '127.0.0. +1', '_SESSION_CTIME' => 1230152786, '_SESSION_ATIME' => 1230152997, ' +_SESSION_EXPIRE_LIST' => {}, '_QUERY' => bless( { '.parameters' => [ +'action', 'message', 'reply' ], 'use_tempfile' => 1, '.tmpfiles' => { +}, '.charset' => 'ISO-8859-1', '.fieldnames' => {}, '.cookies' => { ' +CGISESSID' => bless( { 'value' => [ '45e0195a202edc839b7ae42491f05d43 +' ], 'name' => 'CGISESSID', 'path' => '/' }, 'CGI::Cookie' ) }, 'para +m' => { 'reply' => [ 'Reply' ], 'message' => [ ' this is the message ' ], 'action' => [ 'reply' ] }, 'escape' => 1 }, 'CGI' ), '_DRIVER_ARG +S' => { 'DataColName' => 'a_session', 'Directory' => 'E:/myweb/sessio +ns', 'IdColName' => 'id', 'TableName' => 'sessions' }, '_DSN' => { 's +erializer' => 'default', 'id' => 'md5', 'driver' => 'file' } }, 'CGI: +:Session' );
Thanks and have a Merry Christmas!

Replies are listed 'Best First'.
Re: CGI::Session get the value of
by ikegami (Patriarch) on Dec 24, 2008 at 05:40 UTC
    Why are you looking at the internal structure of the object instead of the docs? Looks like ->param('message')
      Thanks, that doesn't work, which really puzzles me.
      $session->param('_SESSION_ATIME'); # works $session->param('message'); # doesn't work
      The first line works but the second doesn't (value is undef).

        You are likely starting a new session every page load.

        Try this for debugging, when the form pops up, print as part of the page (much better; STDERR if you got shell access) what the initial session id is, then in the next page (runmode that client submits to) print it out again, are they the same? I'm guessing 'no'.

        Why not?

        Last time i checked, CGI::Session does not take care of passing cookie by default. That is.. you create a session (a temporary storage likely in your server) but then.. how the heck do you know next time what session to fetch- if you have ten user clients? The user client has to tell the server what session- this is done in a variety of ways.You'll likely be using a cookie.

        Read the manuals. Read them again, and again. You will be reading a lot. More than that. You will see how reading the manual for thirty minutes is worth it when your coding takes five minutes to write and works the second time off.

        Ahahaha.. wait a second..
        In your receiving end.. you call session->param('message') immediately? Why ? Shouldn't you call cgi->param('message') ? Why would it be in session unless you specifically stored it there?