in reply to A rotten cookie
I'm prepared for any downvoting for a request like this but at this point
What kind of community places views asking for an example of something as negative?
Can someone show me a very basic snippet for checking to see if a cookie exists, if it doesn't print a form and use whatever data they present from the form as the cookie?
Certainly, assuming you know how to print out HTML documents, Using CGI.pm you would do the following:
use CGI; my $q = new CGI; my $cookie = $q->cookie(-name=>'form_info') || ''; if ($cookie) { # you have the cookie, validate the info or whatever now } elsif ($q->param('form_info')) { # you've received the form info # now set the cookie my $cookie_to_send = $q->cookie(-name=>'form_info'); # print out header print $q->header(-cookie=>$cookie); # print out HTML header, then html document } else { # no cookie or form params received # print out HTML form }
Hope that helps :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: A rotten cookie
by sulfericacid (Deacon) on Aug 05, 2003 at 09:45 UTC | |
by thraxil (Prior) on Aug 05, 2003 at 15:59 UTC |