20,360
社区成员
发帖
与我相关
我的任务
分享
$this->display('login');
public function login() {
echo C('SESSION_ADMIN_NAME') ? C('SESSION_ADMIN_NAME') : "NULL";
顺着再看看你配置是不是能正确的读取。
<?php
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";
?>
看看两个环境下的输出有什么区别,你这样顺藤摸瓜总能出来的
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');
但不知为何本地测试时,也执行到这句代码,却没有跳转到登录页面?
$this->display('main');
}
public function main() {
$this->display('center');
}
这个 $this->display('center'); ... ...
if (strtolower(ACTION_NAME) != 'logout') {
$this->redirect("Index/index");
}
... ...
登录页面刷新后出现:页面无法加载,此网页包含重定向循环
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');