Re: sessions and redirecting in opera
On Mon, 13 Aug 2007 00:24:18 +0200, amygdala <noreply@norepl y.comwrote:
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
On Mon, 13 Aug 2007 00:24:18 +0200, amygdala <noreply@norepl y.comwrote:
Rik wrote:
>
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_c lose();
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=0, pre-check=0', 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="' . $url. '">here</aif 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 added
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 for
the
redirect to work and revalidate the url I landed on before I had to log
in.
>On Fri, 10 Aug 2007 20:07:03 +0200, amygdala <noreply@norepl y.com>
>wrote:
>>
>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('Locati on: /first.html');
>header('Locati on: /second.html');
>>
><?php
>//this will end in /first.html
>header('Locati on: /first.html');
>flush();
>header('Locati on: /second.html');
>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
>>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('Locati on: /first.html');
>header('Locati on: /second.html');
>>>
><?php
>//this will end in /first.html
>header('Locati on: /first.html');
>flush();
>header('Locati on: /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_c lose();
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=0, pre-check=0', 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="' . $url. '">here</aif 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 added
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 for
the
redirect to work and revalidate the url I landed on before I had to log
in.
try it in Opera here. Never gave me problems before.
--
Rik Wasmus
Comment