homepage Welcome to WebmasterWorld Guest from 54.198.139.141
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Different between PHP header(location: ...) and meta refresh
jamesyap




msg:1275767
 4:45 pm on Dec 1, 2002 (gmt 0)

There are 2 ways of redirecting.

1st is using the popular meta refresh tag.

2nd is using the header() function in PHP.

Although they both redirect page, I actually want to know how they are different with each other. I mean how do both of them redirect pages (technically).

 

lorax




msg:1275768
 5:41 pm on Dec 1, 2002 (gmt 0)

Meta Refresh is client side - it depends upon the client's computer to tick away the time to the alloted refresh point at which time the browser request the URL indicated.

header("location...") is server side and depends upon the PHP script calling it before it will send the new page to the client.

jatar_k




msg:1275769
 7:01 pm on Dec 1, 2002 (gmt 0)

this thread
[webmasterworld.com...]

talks about some behaviours of refreshes with php. It might give some insight.

andreasfriedrich




msg:1275770
 11:31 pm on Dec 1, 2002 (gmt 0)

The Refresh HTTP header field is non-standard. As already mentioned by lorax it tells the UA to request a certain resource after a certain period of time.

The Location HTTP header field contains the location where the UA will find a certain resource. The exact meaning depends on the HTTP status code and/or context of other header fields. The UA will need to request the new resource.

Both methods originate at the server. Both methods tell the UA that it should do something locally, i.e. request a certain resource.

Andreas

jamesyap




msg:1275771
 5:33 am on Dec 4, 2002 (gmt 0)

Yep, this are the answers I need, thanks 3 of you.

So my worries is now confimed. My refresh, are used to redirect affliate link. (AL) An AL is actually another redirect too! So, my 1st page redirect it to the AL and the AL will redirect to the advertiser. The important role of the AL is to track the # of click and MOST important, plant a cookie to the visitor computer!

So if header is server side, does it means the cookie will not be planted in the visitor computer. And most likely is planted in the server computer?! :)

So my conclusion is - it is safer to use meta refresh to redirect AL. Please advice.

James Yap

andreasfriedrich




msg:1275772
 10:57 pm on Dec 4, 2002 (gmt 0)

So if header is server side, does it means the cookie will not be planted in the visitor computer. And most likely is planted in the server computer?!

No. The server issues the http header and sends the http message to the client. The client then requests the new page.

The communication is always between client and server. The client requests a page the server answers: the resource is not here. Look at this URI and please store this cookie. It is then up to the client to decide whether he wants to request the resource from the new URI and store the cookie. If it decides to follow the serverīs advice, it will then request the resource from the other server which may either send back the resource in an http message with a 200 OK status, redirect the client again or do a lot of other things.

Always remember that with a Location or Refresh header one server does not redirect the client directly to another server. It just lets the client know where to look any further.

Andreas

jamesyap




msg:1275773
 1:42 pm on Dec 5, 2002 (gmt 0)

Hi Adrea, thanks very much for your information because I prefer the use of header more then meta refresh more because the refresh are a lot faster (in my case) and in the way of redirecting to the advertiser, IE will not show up the intermediate URL in the status bar. This is what I like, but also what I worried for. But I agree with the server request and client response and I have also read the PHP manual and cookie manual on 'header'. I think what you say is definitely correct. :)

James Yap

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved