in reply to Lossing session value

Add in $cgi or you get a new session each time. Get the session id

# Create new session my $session = new CGI::Session("driver:File", $cgi, {Directory => 'ses +'}) or die CGI::Session->errstr;; my $sid = $session->id();

Add the session parameter in here. Use .= to ensure a string and not a file handle.

my $got_file_name .= $cgi->param( 'doc_upload' ) || $session->param( 'doc_uploaded' ) || '';

Write the session to disk with flush

# Store file name to use later. $session->param("doc_uploaded", $got_file_name); $session->flush;

Store the session id in a cookie

my $cookie = $cgi->cookie(CGISESSID => $sid); print $cgi->header(-cookie=>$cookie ), $tmpl->output;

Add sessionid to redirect

print "Location: https://myserver/mini.pl?conf=1;CGISESSID=$sid\r\n +\r\n";
poj

Replies are listed 'Best First'.
Re^2: Lossing session value
by Anonymous Monk on Dec 13, 2017 at 19:30 UTC
    I added this new code you suggested, plus the others:

       print "Location: https://myserver/mini.pl?conf=1;CGISESSID=$sid\r\n\r\n";

    Now I get this in my browser:

    "This page isn’t working redirected you too many times."

    And nothing gets displayed!

      I'm not exactly sure what you are trying to achieve but revise the logic like this

      # To prevent re-entering data twice by refreshing page. if ($conf_msg){ confirmation($conf_msg) } else { process_request($got_file_name, $date_ntime); }
      poj