$ this-> Session-> read('Config')在cakephp中不打印任何内容

伊普西塔鲁特

当我尝试打印时$this->Session->read('Config'),它什么也不打印。

我正在使用cakephp 2.5.3

我从网上搜索,阅读了许多博客,帖子和评论,并试图解决它,但我的问题仍然存在。尽管$this->Session->setFlash()工作正常,但其他会话值却不起作用。

App::uses('Controller', 'Controller');
class AppController extends Controller {
    var $components = array('Session','RequestHandler');


    public function beforeFilter() {
        parent::beforeFilter();

        debug($this->Session->read('Config'));//null
        debug($this->Session->read('Config.userAgent'));//null
        debug($this->request->clientIp());// ::1

    }
}
生死
 please check that at the time of login you create a session or not.

那是$ this-> Session-> write('variable name','variable value')。如果您不这样做,那么您的代码将为null。相同的代码为我提供了有关系统中已登录用户的信息。因此,请确保在登录时使用一些变量名和值组合创建了一个会话。请看看这个:

public function login() {

        if ($this->request->is('post') || $this->request->is('put')) {
            $user_detail = $this->User->find('first',array('conditions'=>array('username'=>$this->request->data['User']['username'], 'password'=>$this->Auth->password($this->request->data['User']['password'])),'recursive'=> -1,'fields'=>array('deleted'))); // gettin user details
            if(isset($user_detail) && !empty($user_detail)){
                if($user_detail['User']['deleted']== '0'){
                    if ($this->Auth->login()) {// checking user is authorize for login or not?
                        $this->Session->write('user_role', $this->Auth->user('role_id'));// if yes create session variable with the given variable name and value.
                        $is_incharge = $this->check_incharge($this->Auth->user('id'));
                        if ($is_incharge) {
                            $this->Session->write('is_user_incharge', true);
                        } else {
                            $this->Session->write('is_user_incharge', false);
                        }
                        $this->redirect($this->Auth->loginRedirect);
                    } else {
                        $this->Session->setFlash(__('Invalid User name or Password.'));
                        $this->redirect($this->Auth->logoutRedirect);
                    }
                }else{
                    $this->Session->setFlash(__('You are deleted.Can not login.'));
                    $this->redirect($this->Auth->logoutRedirect);
                }
            }else{
                $this->Session->setFlash(__('Invalid User name or Password..'));
                $this->redirect($this->Auth->logoutRedirect);
            }
        }
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

CakePHP分页“条件”受$ this-> Session-> read()限制

来自分类Dev

类不打印任何内容

来自分类Dev

链表不打印任何内容

来自分类Dev

在批处理脚本中 for 循环后不打印任何内容

来自分类Dev

为什么程序不打印任何内容

来自分类Dev

从终端查询不打印任何内容

来自分类Dev

从终端查询不打印任何内容

来自分类Dev

execvp在fgets之后不打印任何内容

来自分类Dev

beautifulsoup4不打印任何内容

来自分类Dev

ng-repeat不打印任何内容

来自分类Dev

子进程不打印任何内容

来自分类Dev

程序终止,不打印任何内容

来自分类Dev

遍历ArrayList-不打印任何内容

来自分类Dev

从终端查询不打印任何内容

来自分类Dev

read()返回正值,但recvline中没有任何内容

来自分类Dev

Jsoup-打印element.data()不打印任何内容

来自分类Dev

打印shell脚本不打印任何内容

来自分类Dev

在cakephp中找不到变量$ config

来自分类Dev

在Bash中,为什么`x = 100 echo $ x`不打印任何内容?

来自分类Dev

使用调度程序时,System.out.println在RxJava中不打印任何内容

来自分类Dev

Java打印代码正常工作,发送到打印机但不打印任何内容(Python中的Java)

来自分类Dev

Java打印代码正常工作,发送到打印机但不打印任何内容(Python中的Java)

来自分类Dev

$_GLOBAL variables set in config file are not being read correctly

来自分类Dev

转码:为什么此转码不打印任何内容

来自分类Dev

为什么我的python代码不打印任何内容?

来自分类Dev

为什么我的程序最后不打印任何内容?

来自分类Dev

为什么此代码不打印任何内容?

来自分类Dev

功能不起作用(不打印任何内容)

来自分类Dev

为什么我的python脚本不打印任何内容

Related 相关文章

热门标签

归档