Hello. I'm new here and I had just began using Perl CGI.
I'm trying to have a link from my website to another website which requires a cookie to be created in advance. I've been trying to do this with the minimum steps necessary. So far, I've been unsuccessful using the code below. The cookie is printed instead as text on my website while the redirect returns a status 302 message.
Is there a way of doing this without creating a 2nd perl script that does the printing of the cookie header and the link to the 2nd website?
I would appreciate any help or suggestions. Below is the code.
------------------------------------------------------
#!/usr/bin/perl -wF
use CGI qwstandard :netscape :html3 :cgi-lib :shortcuts :br );
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $cgi = new CGI;
use strict;
#the html page
print "Content-type:text/html\n\n";
print "<html><h2>Cookie for Website2</h2><ul>";
print "<li>Test Creating Cookie: </ul>";
my $website2 = ' #for testing only. Not a real website
my $cookie = cookie(
-name => 'cookie1',
-value => "key1=key1:adt=adt1:locn=locn1",
-expires => '+240s',
-domain => '.xyzcompany.com',
-path => '/',
-secure => 1
);
print header(-target=>'_blank', -cookie => $cookie);
print br, center(font({-size=>'+1'}, a({-target=>'_blank',-href=>$website2}, "Link to 2nd Website")));
#print redirect (-uri=>"$website2", -cookie=>"$cookie\n\n");
print "</html>";
----------------------------------
I'm trying to have a link from my website to another website which requires a cookie to be created in advance. I've been trying to do this with the minimum steps necessary. So far, I've been unsuccessful using the code below. The cookie is printed instead as text on my website while the redirect returns a status 302 message.
Is there a way of doing this without creating a 2nd perl script that does the printing of the cookie header and the link to the 2nd website?
I would appreciate any help or suggestions. Below is the code.
------------------------------------------------------
#!/usr/bin/perl -wF
use CGI qwstandard :netscape :html3 :cgi-lib :shortcuts :br );
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $cgi = new CGI;
use strict;
#the html page
print "Content-type:text/html\n\n";
print "<html><h2>Cookie for Website2</h2><ul>";
print "<li>Test Creating Cookie: </ul>";
my $website2 = ' #for testing only. Not a real website
my $cookie = cookie(
-name => 'cookie1',
-value => "key1=key1:adt=adt1:locn=locn1",
-expires => '+240s',
-domain => '.xyzcompany.com',
-path => '/',
-secure => 1
);
print header(-target=>'_blank', -cookie => $cookie);
print br, center(font({-size=>'+1'}, a({-target=>'_blank',-href=>$website2}, "Link to 2nd Website")));
#print redirect (-uri=>"$website2", -cookie=>"$cookie\n\n");
print "</html>";
----------------------------------