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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...