Thank you! This is the closest I've been to getting anything to work. I can get to the 2nd loop (elsif) but for some reason it won't set the cookie and it won't process the if($cookie). I do a test print on $cookie to see what it contains and it never contains anything, why would that be?
I got confused when you assigned $cookie_to_send to the cookie but printed to header the cookie instead of $cookie_to_send so I tried using both variations; neither errored and neither stored anything in the cookie. Any ideas why?
Thanks so much!
my $code = param('name');
my $cookie = cookie(-name=>'test') || '';
if ($cookie) {
} elsif ($code) {
my $cookie_to_send = cookie(-name=>'test'
-value=>"$code",
-expiration=>'+1h');
# print out header
print header(-cookie=>$cookie_to_send);
print "You had a cookie!<br>";
print "Code: $code<br>";
print "Cookie: $cookie";
} else {
print header, start_html;
print "You have no cookie";
print start_form( -action => '' ),
table(
Tr( td("Name:"), td( textfield( -name => 'name', -size => '15
+' ) ) ),
Tr( td("Email:"), td( textfield( -name => 'email', -size => '15
+' ) ) ),
Tr( td( submit('send') ), ),
end_form,
);
}
"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"
sulfericacid
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.