[PHP] Re: header() refresh vs location
The Refresh directive is a valid header. I've used it for many years and it seems to be supported by the majority of browsers. However I've never read anything that would indicate that Refresh works any differently than Location. The only difference is that Refresh allows you to set a number of seconds before redirecting to the given URL. As to whether or not it will solve your problem is something only you can answer. - Kevin Chris Hubbard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] All, I have done a number of searches. I have read the online documentation and user supplied comments. I recently ran into problem using: -some code here to create session and set variables- header('Location: index.php'); where the sessions would sometimes get lost, they wouldn't make it to the index.php page. A print_r on $_SESSION would display an empty array. And yes the sessions are getting set properly. The same code works on three different servers, with no modifications. So a friend recommended using: header (Refresh: 0; url=index.php); I haven't seen documentation for refresh in the header function. Is there any reason to use one in lieu of the other? Any comments on 'refresh'? As I said, I've looked at the online documentation: this page: http://us4.php.net/manual/en/function.header.php doesn't have the word refresh on it. this page: http://www.w3.org/Protocols/rfc2616/rfc2616 doesn't have the word refresh on it. this page: http://us4.php.net/manual/en/function.headers-sent.php does have the word refresh but it's not relevant. Thanks in advance. Chris Hubbard [EMAIL PROTECTED] www.wildcharacters.com 425 481 2020 php based web application development Y! [EMAIL PROTECTED] MSN [EMAIL PROTECTED] AIM ganeshacph
Re: [PHP] Re: header() refresh vs location
--- Kevin Stone [EMAIL PROTECTED] wrote: The Refresh directive is a valid header. I've used it for many years and it seems to be supported by the majority of browsers. My experience has been the same. However I've never read anything that would indicate that Refresh works any differently than Location. Well, it does, though the difference may not be so obvious. The Location header accompanies a response with a status code of 3xx, which tells the Web client that the resource has moved. This matters when it comes to things like Google indexing your site. Google will fetch the new resource and consider it the same as the original resource as long as the status code was 3xx. It is also more transparent; a 3xx response does not exist in the client's history mechanism (well, it's not supposed to), so a user who clicks back won't be sent forward immediately (making the back button appear broken or disabled). I'm not sure if Refresh is interpreted as being transparent in the history as well, but in my current browser (Galeon), it is definitely not. Oh, and the original problem was likely due to a relative URL being used in the Location header. This is a violation of the protocol and can cause problems with certain clients. Hope that helps. Chris = My Blog http://shiflett.org/ HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: header() refresh vs location
* Thus wrote Chris Shiflett ([EMAIL PROTECTED]): --- Kevin Stone [EMAIL PROTECTED] wrote: The Refresh directive is a valid header. I've used it for many years and it seems to be supported by the majority of browsers. My experience has been the same. However I've never read anything that would indicate that Refresh works any differently than Location. Well, it does, though the difference may not be so obvious. The Location header accompanies a response with a status code of 3xx, which tells the Web client that the resource has moved. This matters when it comes to things like Google indexing your site. Google will fetch the new resource and consider it the same as the original resource as long as the status code was 3xx. It is also more transparent; a 3xx response does not exist in the client's history mechanism (well, it's not supposed to), so a user who clicks back won't be sent forward immediately (making the back button appear broken or disabled). I'm not sure if Refresh is interpreted as being transparent in the history as well, but in my current browser (Galeon), it is definitely not. Correct. Also, a 3xx response should not render the content that is included with the response, unless the client doesn't support 3xx (rare) or the user wishes that the browser not to redirect automatically. The refresh header will render the html and start the timer for the refresh once the rendering is done, which does effect the history of the browser. Curt -- My PHP key is worn out PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php