PHP 重定向不起作用,会话已启动 [英] PHP Redirection not working, session has been started
本文介绍了PHP 重定向不起作用,会话已启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图让 PHP 重定向在登录表单中工作,但是,它不起作用.这是验证成功的代码.
I'm trying to get PHP redirection to work, in a login form, however, it is not working. Here's the code if the authentication is successful.
$success = (isset($_POST['uri'])) ? '' : '/index.php';
if ($rs->num_rows) {
$qn = $db->query("SELECT userid FROM sessions");
$svt = array();
$vbs = $rs->fetch_assoc();
while ($row = $qn->fetch_assoc()) {
$svt [] = $row ['userid'];
}
if (in_array($vbs ['userid'], $svt)) {
} else {
set_session(array_merge($vbs, array('expires' => time() + (30 * 60))));
$_SESSION['secure3d']['expires'] = time() + (5 * 60);
header("Location: $success"); // this isn't working but the session is set.
}
}
对我在这里做错了什么有什么想法吗?
Any ideas on what I'm doing wrong here?
推荐答案
尝试将 $success 作为绝对 URI,例如 http://mydomain.com/index.php 例如在 http/1.1 中,它必须是绝对 URI
Try $success as an absolute URI, something like http://mydomain.com/index.php e.g. in http/1.1 it has to be an absolute URI
另一个流行的错误是在头函数之前发送了一个空格.如果您有一个以 "?>"
Another popular error is that an whitespace is send before the header function. This can be happen if you have an include which ends with "?> "
这篇关于PHP 重定向不起作用,会话已启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文