This is a discussion on sessions and redirecting in opera within the PHP Language forums, part of the PHP Programming Forums category; amygdala wrote: > Jerry Stuckle wrote: >> amygdala wrote: >>> "Jerry Stuckle" <jstucklex@attglobal....
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
amygdala wrote:
> Jerry Stuckle wrote: >> amygdala wrote: >>> "Jerry Stuckle" <jstucklex@attglobal.net> schreef in bericht >>> news:xqKdnb9U2fBnMyLbnZ2dnUVZ_uLinZ2d@comcast.com. .. >>>> amygdala 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=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</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 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. >>>>> >>>>> Does anyone have any other clue as to what might be going on here? >>>>> >>>>> Thanks. >>>> Why are you sending a message they will never see, anyway? Normally a >>>> redirect header has NO text associated with it. >>>> >>>> If you have your header set up appropriately, they will be >>>> redirected. All the message might do is screw things up for the >>>> browser. >>> PS.: Correct me if I'm wrong, but are my headers not set up properly? >>> >>> >> Well, I don't see why you have the session_write_close() - the session >> will be closed during exit() processing, anyway. >> >> I also don't see why you have all of the cache control stuff. It's >> completely unnecessary in this case. >> >> Keep it simple - the 302 moved and location should be all you need. > > I would think so to, but if you have read the entire thread you would see > that I am having trouble with getting it to work as expected in Opera. So I > thought I'ld use every option at my disposal to make sure the redirect and > the session saving works as expected. > > But now, it looks like the Opera problem only exists when accessing the > application local on localhost. (See my reply to Rik) > > Yes, I did read the entire thread. That's why I said it. Don't use options just because they're there. Use them because there is a need for them. For instance - the cache control would have no effect on them, and using them just complicates matters. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
Jerry Stuckle wrote:
> amygdala wrote: >> Jerry Stuckle wrote: >>> amygdala wrote: >>>> "Jerry Stuckle" <jstucklex@attglobal.net> schreef in bericht >>>> news:xqKdnb9U2fBnMyLbnZ2dnUVZ_uLinZ2d@comcast.com. .. >>>>> amygdala 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=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</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 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. >>>>>> >>>>>> Does anyone have any other clue as to what might be going on >>>>>> here? Thanks. >>>>> Why are you sending a message they will never see, anyway? >>>>> Normally a redirect header has NO text associated with it. >>>>> >>>>> If you have your header set up appropriately, they will be >>>>> redirected. All the message might do is screw things up for the >>>>> browser. >>>> PS.: Correct me if I'm wrong, but are my headers not set up >>>> properly? >>> Well, I don't see why you have the session_write_close() - the >>> session will be closed during exit() processing, anyway. >>> >>> I also don't see why you have all of the cache control stuff. It's >>> completely unnecessary in this case. >>> >>> Keep it simple - the 302 moved and location should be all you need. >> >> I would think so to, but if you have read the entire thread you >> would see that I am having trouble with getting it to work as >> expected in Opera. So I thought I'ld use every option at my disposal >> to make sure the redirect and the session saving works as expected. >> >> But now, it looks like the Opera problem only exists when accessing >> the application local on localhost. (See my reply to Rik) >> >> > > Yes, I did read the entire thread. That's why I said it. Don't use > options just because they're there. Use them because there is a need > for them. I don't use them because they are there, I use them because every other option in my mind was exhausted, so I thought I'ld give it a try and one by one remove a header to see where the problem would arise in Opera. But I started off putting them all in there for debugging purposes. session_write_close(): because with Opera I was getting multiple session entries in my DB. And I know this doesn't make sense logically (I can tell client processes from server processes) and I know an exit() statement should suffice, yada yada yada. Cache-Control and other cache headers: because I thought Opera might somehow not revalidate the initial redirected url. But to tell you the truth, I don't see how any cache headers could harm: header( 'HTTP/1.0 302 Moved Temporarily' ); header( 'Location: ' . $url ); |