Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: redirection failing when cookie is set
by kutsu (Priest) on Sep 08, 2004 at 20:44 UTC | |
by bradcathey (Prior) on Oct 05, 2004 at 15:44 UTC | |
by Anonymous Monk on Sep 09, 2004 at 13:17 UTC | |
by wfsp (Abbot) on Sep 09, 2004 at 14:13 UTC | |
by Anonymous Monk on Sep 09, 2004 at 14:44 UTC | |
by kutsu (Priest) on Sep 09, 2004 at 15:02 UTC | |
by Anonymous Monk on Sep 09, 2004 at 15:09 UTC | |
by Anonymous Monk on Sep 09, 2004 at 16:46 UTC | |
|
Re: redirection failing when cookie is set
by sandfly (Beadle) on Sep 08, 2004 at 22:19 UTC |