Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks!
All that I am trying to do here is to set these cookies (the cookies part work if) and redirect to another page after the cookies get set, but if I use any of the methods here the cookies will not work. Why?
Can someone give me a hand on that please?
I tried all of them.
Here is the code:
Thanks a lot!!!!
All that I am trying to do here is to set these cookies (the cookies part work if) and redirect to another page after the cookies get set, but if I use any of the methods here the cookies will not work. Why?
Can someone give me a hand on that please?
I tried all of them.
Here is the code:
#!/usr/bin/perl use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use strict; use DBI; use CGI qw(:all); my $query = new CGI; my $name="Joe X"; my $buddy = "more Numbers XY"; my $cookie1 = $query->cookie(-name=>'name', -value=>"$name", -expires=>'+4h', -path=>'/'); my $cookie2 = $query->cookie(-name=>'buddy', -value=>"$buddy", -expires=>'+4h', -path=>'/'); print $query->header(-cookie=>[$cookie1,$cookie2]); my $got_cookie1 = $query->cookie('name'); my $got_cookie2 = $query->cookie('buddy'); if($f_name eq ""){$name = $got_cookie1;} if($buddy eq ""){$buddy = $got_cookie2;} print "<meta http-equiv=\"refresh\" content=\"2\";\ url=http://www.myp +age.com/cgi-bin/per.pl?buddy=$buddy&name=$name\">"; print $query->redirect('http://www.mypage.com/cgi-bin/per.pl?buddy=$bu +ddy&name=$name'); my $url = "http://www.mypage.com/cgi-bin/per.pl?buddy=$buddy&name=$nam +e"; print "Location: $url\n\n"; print $query->end_html;
Thanks a lot!!!!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Setting Cookies First and Redirecting Page
by chargrill (Parson) on Sep 15, 2006 at 18:24 UTC | |
by Anonymous Monk on Sep 15, 2006 at 18:41 UTC | |
Re: Setting Cookies First and Redirecting Page
by robartes (Priest) on Sep 15, 2006 at 21:19 UTC | |
Re: Setting Cookies First and Redirecting Page
by ptum (Priest) on Sep 15, 2006 at 18:24 UTC | |
by Anonymous Monk on Sep 15, 2006 at 18:42 UTC | |
by ptum (Priest) on Sep 15, 2006 at 18:52 UTC | |
by Anonymous Monk on Sep 15, 2006 at 19:14 UTC | |
by derby (Abbot) on Sep 15, 2006 at 20:09 UTC | |
by ptum (Priest) on Sep 15, 2006 at 19:52 UTC |
Back to
Seekers of Perl Wisdom