1.

Is It Possible To Set A Cookie And Then Redirect A Return Visitor To A Different Url All Using Cgi?

Answer»

Try:

#! /usr/bin/perl -w
use CGI qw(:cgi);
my $q = CGI->new();
my $cookie = $q->cookie(
-name => 'yummy_cookie',
-value => 'chocolate chip',
-DOMAIN => '.wisdomjobs.com',
-expires => '+10d',
-PATH => '/'
);
print $q->redirect(
-URL => 'http://www.wisdomjobs.com',
-cookie => $cookie
);

__END__

If you leave out the "-domain", and "-path", then they will default to CURRENT values. The above example will be returned to all servers in the irt.org domain.

If you leave out the "-expires", then the cookie will expire when the user closes their BROWSER. The above expires after 10 days.

Try:

#! /usr/bin/perl -w
use CGI qw(:cgi);
my $q = CGI->new();
my $cookie = $q->cookie(
-name => 'yummy_cookie',
-value => 'chocolate chip',
-domain => '.wisdomjobs.com',
-expires => '+10d',
-path => '/'
);
print $q->redirect(
-url => 'http://www.wisdomjobs.com',
-cookie => $cookie
);

__END__

If you leave out the "-domain", and "-path", then they will default to current values. The above example will be returned to all servers in the irt.org domain.

If you leave out the "-expires", then the cookie will expire when the user closes their browser. The above expires after 10 days.



Discussion

No Comment Found