I have a page with a drop-down menu to select a region, and a check mark to allow the region to be remembered in future sessions.
When the user selects a region and clicks on "GO", the redirection works. If the user checks the "Remember my selection" box, a cookie is set, but redirection fails. The browser merely displays "Location: http://www.somelocation.com".
Also, how can I get it so that, after the cookie is set, it will automatically be retrieved when the main page is called, so that redirection will automatically take place and appear invisible to the user?
Thanks
use CGI qw/:standard/;
my $query = new CGI;
my $cookie_in = $query->cookie('region');
if ($cookie_in) {
if ($cookie_in eq "americas") {
print "Location: http://www.google.com\n\n";
}
elsif ($cookie_in eq "canada") {
print "Location: http://canada.gc.ca\n\n";
}
else {
print "Location: http://www.belimo.org\n\n";
}
}
else {
my $checked = param(checked);
my $region = param(region);
if ($checked eq "yes") {
my $cookie_out = $query->cookie(-name=>'region',-value=>$reg
+ion,-expires=>'Saturday, 31-Dec-04 16:00:00
+GMT',-path=>'/',-domain=>'194.69.170.21');
print $query->header(-cookie=>$cookie_out);
}
if ($region eq "americas") {
print "Location: http://www.google.com\n\n";
}
elsif ($region eq "canada") {
print "Location: http://canada.gc.ca\n\n";
}
else {
print "Location: http://www.belimo.org\n\n";
}
}