I had the identical same problem as you using IE5 and PWS.  The redirect
"works" in that it generates the "has moved" stuff.  I'm sure there is a
better way to do this but I used the "refresh" function instead of
"redirect" as follows to get around it:

      $cookie1 = cookie(-name=>'Whatever', -value=>'Some
value', -expires=>'+3M');
      $cookie2 = cookie(-name=>'Another', -value=>'Another
value', -expires=>'+3M');
      print header(-expires=>'-1d', -cookie=>[$cookie1,$cookie2], -Refresh=>
'4; URL=http://www.yourdomain.com/');
      print start_html(-title=>'www.yourdomain.com Login Processing');
      print "<H1>Welcome $FullName.</H1>\n";
      print "If you are not automatically taken to the main menu in 4
seconds click <A HREF=\"/main.htm\">here</A>.<P>\n";

If you didn't want them to see anything you could just skip outputting any
sort of page and set the delay to 0 instead of 4.  I like to give them the
page so they can click through in case their browser doesn't do the refresh
for some reason.

I haven't read the HTTP RFC to see if a "Location" (redirect) and "Cookie"
header are "legal" together or not.  It seems that when I read Lincoln
Stein's CGI.pm book it said they wouldn't work together.  If this is true,
it obviously has nothing to do with CGI.pm as it will write out whatever you
tell it to, it's just a matter of whether or not the browsers will allow and
understand it.  Obviously when using cookies to give someone a security
"token" that allows them further access throughout the site being able to do
a redirect/cookie header is desirable when setting that cookie for the first
time.

The only downside to my solution above over a "redirect" is that if the user
presses their "back" button they can back into that screen which could
concievably cause unexpected results depending on the particulars of your
implementation.  I'd certainly be interested in any concrete resolution to
the redirect/cookie issue if one appears.

----- Original Message -----
From: "Roland Corbet" <[EMAIL PROTECTED]>
To: "Dave Dunstan" <[EMAIL PROTECTED]>; "'$Bill Luebkert'" <[EMAIL PROTECTED]>;
"'Dave Dunstan'" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, November 22, 2000 6:30 AM
Subject: RE: set cookie, then redirect


> At 19:19 20/09/2000, Dave Dunstan wrote:
> >OH! Sweet. Thanks again Bill. You are becoming my personal Perl hero ...
>
> I'm guessing that means it worked? ;-)  I have tried the following, but it
> produces the following output:
>
> Status: 302 Moved Set-Cookie: Test=Test%20Data; path=/scripts;
expires=Tue,
> 20-Feb-2001 11:24:40 GMT Date: Wed, 22 Nov 2000 11:24:40 GMT Location:
> http://www.psyche.net.uk
>
> here's what I used to get that output:
>
> use CGI;
> use CGI::Cookie;
> $query = new CGI;
>
> $NAME = "Test";
> $EXPIRY = "+3M";
> $VALUE = "Test Data";
> $PATH = "/scripts";
> $URL = "http://www.psyche.net.uk";
>
> $c = new CGI::Cookie(-name    =>  "$NAME",
>                  -expires =>  "$EXPIRY",
>                  -value   =>  "$VALUE",
>                  -path    =>  "$PATH"
> );
>
> print $query->redirect(-uri=>"$URL", -cookie => ["$c"]);
>
> if I just do:
>
> print $query->redirect(-uri=>"$URL");
>
> on it's own, then it works fine.  It just stops as soon as I add on the
> Cookie part.  Any ideas why it doesn't work, or what is going on?
>
> Many thanks in anticipation of your help.
>
> Regards,
>
> Roland
>
> > > -----Original Message-----
> > > From: $Bill Luebkert [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, September 20, 2000 12:11 PM
> > > To: Dave Dunstan
> > > Cc: [EMAIL PROTECTED]
> > > Subject: Re: set cookie, then redirect
> > >
> > >
> > > Dave Dunstan wrote:
> > > >
> > > > Hey folks, Dave Dunstan here.
> > > >
> > > > I'm wondering how to use CGI.pm to:
> > > > 1) Set a cookie, then
> > > > 2) Redirect to another page ... at the same time.
> > >
> > > Create your cookie and just add -cookie arg on redirect command.
> > >
> > > Something like (untested):
> > >
> > >     print redirect (-uri => $url, -cookie => [$cookie]);
> > >
> > > or $query->redirect(...) for OO method.
>
> --
> Roland Corbet
> Systems Administrator & Developer
> Psyche Solutions Limited
> Chester Road
> Cradley Heath
> West Midlands
> B64 6AB
>
> Tel: + 44 (0)1384 414183 Ext. 4412
> Fax: + 44 (0)1384 414111
> E-Mail: [EMAIL PROTECTED]
> WWW: http://www.psyche.net.uk
>
>
> --
> The information contained within this e-mail sent by Cradley Print Ltd. is
> confidential and is intended for the named recipient only. If you are not
> the intended recipient please notify us by telephone immediately on 01384
> 414100 (UK)or +(44)1384 414100 (International) or return it to us by
e-mail
> quoting the name of the sender and the addressee. Please then delete it
from
> your system.
>
> Encryption and Viruses
> ==================
> Please note that this e-mail and any attachments have not been encrypted.
> They may therefore be liable to be compromised. Please also note that it
is
> your responsibility to scan this e-mail and any attachments for viruses.
> Viruses and compromises of security are inherent risks in relation to
> e-mail.
>
> We do not, to the extent permitted by law, accept any liability (whether
in
> contract, negligence or otherwise) for any virus infection and/or external
> compromise of security and/or confidentiality in relation to transmissions
> sent by e-mail.
>
> Contracts
> ========
> Please note, that contracts may NOT be concluded on behalf of Cradley
Print
> Ltd by e-mail, but contracts on behalf of our clients may be concluded by
> e-mail.
> _______________________________________________
> Perl-Win32-Web mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to