CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...: Re: [RedRum] Cookies 2: Edit Log



yapp
User

Mar 3, 2002, 12:57 PM


Views: 4610
Re: [RedRum] Cookies 2

...This should actually be posted in the beginner/immediate forum...

I throught this does the trick:
[perl]
use CGI qw(:cgi);
my $times = cookie('Cookie_Name') || 0;

if($times > 5) {
print redirect('some_url'); # Your redirect needs to be printed to the browser.
exit;
}
else {
set_cookie();
}

sub set_cookie
{
my $cookieObj = cookie(-name => 'Cookie_Name', -value=> $times);
print header( -cookie => $cookieObj ); # Send cookie with HTTP header
}
[/perl]

btw, use CGI qw(:cgi); would be enough for CGI programs. (unless you want to generate HTML through the CGI.pm

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool

(This post was edited by yapp on Mar 3, 2002, 12:59 PM)


Edit Log:
Post edited by yapp (User) on Mar 3, 2002, 12:59 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives