in reply to Re: Re: How do they expect cookies to work (like this)??
in thread How do they expect cookies to work (like this)??
Sure, I'll bite:
#!/usr/bin/perl -w use strict; use CGI qw(header cookie); if (cookie("val")) { print header(),"Your cookie is still set"; } elsif (param("val")) { print header(-cookie=>cookie( -name =>'val', -value=>param("val"), -expires=>'+1M')),"Success! Your cookie should be set"; } else { print header(),q(<html><body><form method="POST" action=""><input ty +pe="text" name="val"><input type="submit" value="Click here"></form>< +/body></html>); }
Steps: check for the cookie. If present, display still set page. If not, check for a parameter. If present, set the cookie and display success page. If not, display form. I haven't tested the above code, but you should be able to understand what the process entails. I used CGI for all the nasty work. Please click that link and read EVERYTHING. Then check out Ovid's CGI Programming with Perl course.
Hope this helps.
antirice
The first rule of Perl club is - use Perl
The ith rule of Perl club is - follow rule i - 1 for i > 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: How do they expect cookies to work (like this)??
by Anonymous Monk on Sep 30, 2003 at 18:57 UTC | |
by antirice (Priest) on Sep 30, 2003 at 19:15 UTC |