That's because the redirect function probably contains the header function?
The header function will only work if there's absolutely no (HTML) output yet.
Printable View
That's because the redirect function probably contains the header function?
The header function will only work if there's absolutely no (HTML) output yet.
Unfortunately, no.
Unless that is the HTML that you're talking about =PPHP Code://Alert
function alert($msg){
echo '<script language="javascript">alert("'.$msg.'");</script>';
}
//Redirect
function redirect($url){
echo "<body><script>document.location = '$url'</script></body>";
}
EDIT: Hmm, using the redirect function instead of the header function redirects me back to the index page, but it doesnt save the sessions.
There is however HTML in the functions.php since they're part of some of the functions.
EDIT 2: Hmm, using the same thing in the test pages, I use the header function to redirect me back to testing.php, but no sessions are saved.
The test.php page shows the correct sessions, but after it redirects, the sessions have not been saved, like they're not even there.
test.php:
Array ( [UGradeID] => 255 [user] => wesman2232 )
testing.php after redirect with header function:
Array ( [AID] => [PageTitle] => )
I see the header function after the last else.
And before you call that function, you output HTML.
Alright, I see what you're saying.
Now I'm not sure if you noticed my edits, but I tried the header function with my test pages.
Using the same thing in the test pages, I use the header function to redirect me back to testing.php, but no sessions are saved.
The test.php page shows the correct sessions, but after it redirects, the sessions have not been saved, like they're not even there.
test.php:
Array ( [UGradeID] => 255 [user] => wesman2232 )
testing.php after redirect with header function:
Array ( [AID] => [PageTitle] => )
I assume all pages have session_start(); on top? (Before you include other files or call functions.)
Correct. The actual website just includes all the other files which they inherit that session_start();
On the test pages, I just put session_start(); on top of test.php (the login function) and now it worked when redirected. (Probably cause it wasn't included, but actually called)
But I can't get this to work on the actual website to save my life.
Drop me a PM with Skype or Steam if you want. I can probably debug this in under a minute over TeamViewer while it would take days to do it over the forums.