Re: REDIRECT missing Cookie

2000-04-11 Thread Perrin Harkins

Jim Winstead wrote:
> 
> On Apr 08, Zeqing Xia wrote:
> > Hi,
> >
> > I'm having a problem with setting the cookie in a REDIRECT. Basically,
> > I'm doing this in a handler:
> >
> > $r->headers_out->add('Set-Cookie' => $cookie);
> > $r->headers_out->add('Location' => $location);
> > return REDIRECT;
> >
> > The $location is hit but the cookie is missing when I debug the handler
> > for $location.
> >
> > I have tried various remedies, such as no_cache(),
> > unset('Content-length'), etc. But nothing seems have effect.
> >
> > Can anyone point out what is the problem? Thanks so much.
> 
> This is a misfeature of some browsers. (Particular versions of
> Internet Explorer, if I remember correctly.)
> 
> Some people have reported success with some browsers depending on
> the order the headers appear, but the most bullet-proof solution
> is to do a redirect with a header or meta-tag refresh instead of
> an redirect. (Which is definitely not as user-friendly, but works
> for all cookie-enabled browsers that I've come across.)
> 
> So you'd want to do something like:
> 
>   $r->headers_out->add('Set-Cookie' => $cookie);
>   $r->headers_out->add('Refresh' => "0; url=$location");
>   $r->print("Sending you here.");
>   return OK;
> 
> Jim

You could also put the cookie info in the URL you redirect to (as a
query string), and make your handler look for it there if the cookie is
missing.

- Perrin



Re: REDIRECT missing Cookie

2000-04-08 Thread Zeqing Xia


I have tried this but with no success. I'm running NS4.7 on RH6.1. What I
found when I use Apache::Debug::dump() is that if I use a simple string as
the $cookie, the cookie is passed along redirect. However if the $cookie
is an object of CGI::Cookie, it is missing in the redirect request.

Fred Xia

Ken Williams wrote:

> [EMAIL PROTECTED] (Zeqing Xia) wrote:
>
> >Hi,
> >
> >I'm having a problem with setting the cookie in a REDIRECT. Basically,
> >I'm doing this in a handler:
> >
> >$r->headers_out->add('Set-Cookie' => $cookie);
> >$r->headers_out->add('Location' => $location);
> >return REDIRECT;
>
> Try changing to $r->err_headers_out.  Details in the eagle book.
>
>   ------
>   Ken Williams Last Bastion of Euclidity
>   [EMAIL PROTECTED]The Math Forum




Re: REDIRECT missing Cookie

2000-04-08 Thread Ken Williams

[EMAIL PROTECTED] (Zeqing Xia) wrote:

>Hi,
>
>I'm having a problem with setting the cookie in a REDIRECT. Basically,
>I'm doing this in a handler:
>
>$r->headers_out->add('Set-Cookie' => $cookie);
>$r->headers_out->add('Location' => $location);
>return REDIRECT;

Try changing to $r->err_headers_out.  Details in the eagle book.


  ------
  Ken Williams Last Bastion of Euclidity
  [EMAIL PROTECTED]The Math Forum





Re: REDIRECT missing Cookie

2000-04-08 Thread Jim Winstead

On Apr 08, Zeqing Xia wrote:
> Hi,
> 
> I'm having a problem with setting the cookie in a REDIRECT. Basically,
> I'm doing this in a handler:
> 
> $r->headers_out->add('Set-Cookie' => $cookie);
> $r->headers_out->add('Location' => $location);
> return REDIRECT;
> 
> The $location is hit but the cookie is missing when I debug the handler
> for $location.
> 
> I have tried various remedies, such as no_cache(),
> unset('Content-length'), etc. But nothing seems have effect.
> 
> Can anyone point out what is the problem? Thanks so much.

This is a misfeature of some browsers. (Particular versions of
Internet Explorer, if I remember correctly.)

Some people have reported success with some browsers depending on
the order the headers appear, but the most bullet-proof solution
is to do a redirect with a header or meta-tag refresh instead of
an redirect. (Which is definitely not as user-friendly, but works
for all cookie-enabled browsers that I've come across.)

So you'd want to do something like:

  $r->headers_out->add('Set-Cookie' => $cookie);
  $r->headers_out->add('Refresh' => "0; url=$location");
  $r->print("Sending you here.");
  return OK;

Jim