|
Posted by Rik on 08/13/07 09:09
On Mon, 13 Aug 2007 00:24:18 +0200, amygdala <noreply@noreply.com> wrote=
:
> Rik wrote:
>> On Fri, 10 Aug 2007 20:07:03 +0200, amygdala <noreply@noreply.com>
>> wrote:
>>>
>>> Could it be that Opera needs some kind of body content after a
>>> redirection
>>> header? Or could it perhaps be that Opera indeed thinks that it
>>> should redirect back to the login page again, since it is redirected=
>>> to a page, that redirected to the login page in the first place. lol=
>>
>> Possiblity 1:
>> Opera -> Tools -> preferences -> Advanced -> Network -> Enable
>> Automatic Redirection.
>>
>> It's enabled by default, but can be disabled for whatever purpose.
>> All the more reason why a header redirect should be accompanied by
>> some information one is redirected, and a script should die()/exit()
>> after that.
>> Possibility 2:
>> Opera get's the redirect, but still has the page with the same URL in=
>> cache, so decides to use that one. Set some header and/or html
>> information these pages should not be cached.
>>
>> Possibility 3:
>> The script isn't terminated after the first header-redirect,
>> continues to run, and effectively changes the redirect by a second
>> header() call. Putting an echo directly after it will force the
>> headers to be sent, so they cannot be replaced anymore, resulting in
>> the first one being the only one, and thus the one obeyed by the
>> browser. Another example why one should die()/exit() after a redirect=
..
>>
>> <?php
>> //this will offcourse end in /second.html
>> header('Location: /first.html');
>> header('Location: /second.html');
>>>
>>
>> <?php
>> //this will end in /first.html
>> header('Location: /first.html');
>> flush();
>> header('Location: /second.html');
>
> This thing still has me puzzled. What I did is the following:
>
> My SessionHandler class has the following method:
>
> public function redirect( $url )
> {
> session_write_close();
> header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
> header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
> header( 'Cache-Control: no-store, no-cache, must-revalidate' );
> header( 'Cache-Control: post-check=3D0, pre-check=3D0', false );
> header( 'Pragma: no-cache' );
> header( 'HTTP/1.0 302 Moved Temporarily' );
> header( 'Location: ' . $url );
> // this part between the comments is important
> echo 'You\'re being redirected to ' . $url . ' .
> Click <a href=3D"' . $url. '">here</a> if it doesn\'t work';
> // end important part
> exit(); // exit doesn't really make a difference for Opera
> }
>
> Since I have now included the exit() statement I am sure that this is =
the
> last thing done by the application when redirecting. Also, I have adde=
d
> cache control headers and the likes. But still in Opera the problem =
> persists
> if I leave out the echo part you see above between the comments.
>
> So, from my experience it seems as if Opera wants some body content fo=
r =
> the
> redirect to work and revalidate the url I landed on before I had to lo=
g =
> in.
Can you set this up somewhere accessable? I'm curious what happens if I =
=
try it in Opera here. Never gave me problems before.
-- =
Rik Wasmus
[Back to original message]
|