0

I have a header redirect in place which works however it seems to run through my code twice when ied rather it just redirect and then do the code. It seems to do all the code and then redirect and then do all the code. Ive checked this because ive incremented an integer in a session and it comes up to when it actually gets to its destination even though the code to increment the session is AFTER my header redirect.

why is this.

2
  • show us the incriminated code Commented Feb 8, 2011 at 14:41
  • can you please provide us with your code ? Commented Feb 8, 2011 at 14:41

2 Answers 2

4

Hard to say without some code, but this is one i've seen a lot: If you call the header, your code does not stop. So the header sents some stuff to the browser, but the code will keep on running.

If the execution should stop after your header, explicitly call die or exit

Sign up to request clarification or add additional context in comments.

1 Comment

np: I remember I had to go trough some of my own code fixing this :D It explained a lot of strange behaviour :)
1

I recommend putting an exit; after every header redirection. The php code is not terminated when you do the redirect, and this could lead to such behaviour.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.