Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi Larry,

 

Can you please give me your thoughts on two window relocation techniques that I use as to which one, if any, is better.

 

$url and header (in PHP)

 

or JS window.location.replace(url)

 

with the urls set appropriately.

 

window.location.replace seems to be better if you are using sessions to avoid the 'headers already sent' issue but I'd appreciate your advice.

 

Best wishes from Oz

Link to comment
Share on other sites

Personally, I would always do it in PHP if you can. In other words, if the need for redirection is identified in the PHP code, then the redirection should happen there. Conversely, if the user has visited a page already and you want to redirect them without them loading another page, you'd use JavaScript. This should be fairly uncommon. 

Link to comment
Share on other sites

 Share

×
×
  • Create New...