Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: Losing session value

by hippo (Bishop)
on Dec 14, 2017 at 09:34 UTC ( [id://1205510]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Losing session value
in thread Lossing session value

So, here's an SSCCE which works well.

#!/usr/bin/perl use strict; use warnings; use CGI::Session; my $session = CGI::Session->new or die CGI::Session->errstr; my $cgi = $session->query; my $html = '<h1>Session test</h1>'; my $field = 'doc_upload'; # Initial value my $gfn = $session->param ($field); $html .= $gfn ? "<p>Initial value: $gfn</p>" : '<p>No iniital value</p +>'; # New value my $newgfn = $cgi->param ($field); $html .= $newgfn ? "<p>Supplied value: $newgfn</p>" : '<p>No supplied value</ +p>'; if ($newgfn) { $session->param ($field, $newgfn); $html .= '<p>Initial value overwritten with new value</p>'; } $html .= qq{<form method="post"><input type="text" name="$field"/> <input type="submit" value="Submit new value"/></form>}; print $session->header, $html; $session->flush;

The HTML is minimalistic but serves the purpose. Run this CGI a few times to convince yourself that it is indeed storing new values but only when supplied. Then see how this differs from your script and amend yours accordingly. Good luck.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1205510]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-18 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found