public function index() { if (!empty($_SESSION[C('SESSION_ADMIN_NAME')]) && !empty($_SESSION[C('SESSION_ADMIN_ID')]) && strtolower(ACTION_NAME) != 'logout') {
$this->redirect("Index/index"); }
$this->display('login'); } /** * 登录判断 */ public function login() {
public function index() {
if (!empty($_SESSION[C('SESSION_ADMIN_NAME')]) && !empty($_SESSION[C('SESSION_ADMIN_ID')]) && strtolower(ACTION_NAME) != 'logout') {
$this->redirect("Index/index");
}
$this->display('login');
} /**
* 登录判断
*/
public function login() {
我跟踪到!empty($_SESSION[C('SESSION_ADMIN_NAME')])是true, !empty($_SESSION[C('SESSION_ADMIN_ID')])也是true,结果本地、虚拟空间都有执行到语句: $this->display('login');
剩下:if (strtolower(ACTION_NAME) != 'logout') {
$this->redirect("Index/index");
}
... ...登录页面刷新后出现:页面无法加载,此网页包含重定向循环
谢谢回复,点击登录之后 页面跳转到 http://.../Login/login.htm
然后马上又跳转到http://.../Home/Login/index.htm (登录页面)
然后马上自动跳转到 http://.../Index/index.htm
最后又马上自动跳转到http://.../Home/Login/index.htm (登录页面)
$this->display('main');
} public function main() { $this->display('center');
}这个 $this->display('center'); ... ...
public function logout() {
session_destroy();
//cjq add
$fp = fopen('./qerr1f.txt','w+');
fwrite($fp,"ok");
fclose($fp);
$this->redirect('Login/index');
}
跟踪到这段代码了,确实执行到了 $this->redirect('Login/index');
但不知为何本地测试时,也执行到这句代码,却没有跳转到登录页面?
public function logout() {
会被执行到,显然是你弄错了 url
logout 是注销!
多谢!我也不知道为什么logout()会被执行到,三个RUNTIME目录都清空了,还是一样。
我搜索整站代码,只搜到四段调用logout()的代码,都与登录无关。
是哪里的URL搞错了呢?被这个问题搞晕了!
多谢!我也不知道为什么logout()会被调用到,三个runtime目录都清空了,还是一样。
什么地方的url弄错了呢?我被这个问题搞晕了!
session_start();
if(empty($_SESSION['time'])){
$_SESSION['time'] = time();
}
echo $_SESSION['time'];
?>不断刷新该测试页面看看有没有输出时间,同时查看时间是不是在变。
如果时间不断变化,你的服务器没有配置好session
<?php
echo $_SESSION[C('SESSION_ADMIN_NAME') ? $_SESSION[C('SESSION_ADMIN_NAME') : "NULL";
?>看看两个环境下的输出有什么区别,你这样顺藤摸瓜总能出来的
两个环境下都输出NULL,真搞不懂为什么就?
echo C('SESSION_ADMIN_NAME') ? C('SESSION_ADMIN_NAME') : "NULL";顺着再看看你配置是不是能正确的读取。