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:
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
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:
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
Code:
use CGI qw/:standard/;
my $query = new CGI;
my $cookie_in = $query->cookie('region');
if ($cookie_in) {
if ($cookie_in eq "americas") {
print "Location: [URL unfurl="true"]http://www.americas.com\n\n";[/URL]
}
elsif ($cookie_in eq "canada") {
print "Location: [URL unfurl="true"]http://canada.gc.ca\n\n";[/URL]
}
else {
print "Location: [URL unfurl="true"]http://www.un.org\n\n";[/URL]
}
}
else {
my $checked = param(checked);
my $region = param(region);
if ($checked eq "yes") {
my $cookie_out = $query->cookie(-name=>'region',-value=>$region,-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: [URL unfurl="true"]http://www.americas.com\n\n";[/URL]
}
elsif ($region eq "canada") {
print "Location: [URL unfurl="true"]http://canada.gc.ca\n\n";[/URL]
}
else {
print "Location: [URL unfurl="true"]http://www.un.org\n\n";[/URL]
}
}