Is it possible to set a cookie and then redirect a return visitor to a different url all using cgi?
Submitted by: AdministratorTry:
#! /usr/bin/perl -w
use CGI qw(:cgi);
my $q = CGI->new();
my $cookie = $q->cookie(
-name => 'yummy_cookie',
-value => 'chocolate chip',
-domain => '.globalguideline.com',
-expires => '+10d',
-path => '/'
);
print $q->redirect(
-url => 'http://www.globalguideline.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.
Submitted by: Administrator
#! /usr/bin/perl -w
use CGI qw(:cgi);
my $q = CGI->new();
my $cookie = $q->cookie(
-name => 'yummy_cookie',
-value => 'chocolate chip',
-domain => '.globalguideline.com',
-expires => '+10d',
-path => '/'
);
print $q->redirect(
-url => 'http://www.globalguideline.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.
Submitted by: Administrator
Read Online CGI Programming Job Interview Questions And Answers
Top CGI Programming Questions
☺ | What is a CGI bin directory? |
☺ | Can I pass JavaScript variables to a CGI Perl program? |
☺ | How can I stop my CGI script reading and writing files as nobody? |
☺ | How can I run my CGI program live in a debugger? |
☺ | What do I absolutely need to know in CGI? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |