I'm having a very odd problem that I can't seem to track down. Any help with regards to debugging would be greatly appreciated!
Let me describe this using scenarios.
Scenario 1 (incorrect)
curl_exec
) and gets the user info backtop.php
filecurl_exec
) and receives an error since the CAS ticket has already been used, setting a new error message of "CAS rejected your credentials" (which is not correct)top.php
file and doesn't refresh/redirect a second timeScenario 2 (semi-correct)
curl_exec
) and gets the user info backtop.php
since it was commented out, and print out "User not found" (this is the correct error message)Debugging
So, I have checked, double-checked and triple-checked that top.php
doesn't use include
, require
, redirect
(a function we wrote that prints a <meta>
redirect tag and then calls exit;
), or any other thing that actually refreshes the page.
In fact, I've put in a die
statement that prints out the error message. On one line in top.php
, it prints out correctly. When I move that statement down one line (below an HTML </div>
tag), it refreshes the page and prints the incorrect error message. There aren't even any PHP tags anywhere close.
As far as I can tell, this means the problem is not actually in the top.php
file, since printing out </div>
should never cause a page to refresh/redirect.
Any ideas on how to debug from here would be enormously helpful. Clearing caches/buffers? How to better track what PHP is doing?
Note: No PHP errors are being output.
UPDATE: Yay, I found the culprit! Instead of calling include 'top.php';
I simply copied/pasted the code inside login.php
and it presented the same problem. So I began deleting lines until I found the one causing the problem:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
So, switching the question entirely since I didn't have much of a question in the first place: Can someone explain why this causes a page refresh, and why is it only sometimes (i.e. it doesn't continually refresh the page)?
If you have firefox grab yourself a copy of livehttpheaders. Turn it on and go through scenario 1. Trace through the http request and response headers to see what is happening there. It should provide you with more information on just what is happening between the browser and the server.