( This does not answer my question).
I am trying to redirect to the landing page after a user attempts to login, here is what I've done:
<?php
ob_start();
session_start();
if ($loginSuccess)
{
echo "Logged in: True";
header("Location: index.php?status=1", true, 200);
}
else
{
echo "Logged in: False";
header("Location: index.php?status=0", true, 401);
}
ob_end_flush();
exit();
?>
However when I try this I get the page never gets redirected back to the page that the request was made with (index.php)
try put this code before the ob_start()
, becuase the header sometimes already called
ob_clean()
or change to javascript redirect using this if the ob_clean()
not worked
echo "<script>window.location.href='index.php?status=1'</script>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.