首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重定向损失会话cakephp

重定向损失会话cakephp
EN

Stack Overflow用户
提问于 2014-07-23 15:31:36
回答 1查看 195关注 0票数 0

如果用户未登录,我将尝试将会话保存在用户试图输入的变量url中,因此,我重定向到登录URL,并且一旦成功地将其重定向回请求的网站。我的问题是,它没有保存会话变量,也没有保存其中的一个或另一个。

这在appController中

代码语言:javascript
复制
if($this->action!='logout' && $this->action!='logout_cas' && $this->action!='login_cas' && $this->action!='login'){
        if(isset($_SESSION['cas_user'])){
            $_SESSION['url_user'] = Router::url('', true);
            $this->redirect(array('controller'=>'users','action'=>'login_cas'));
        }
    }

这在函数UsersController中的login_cas中

代码语言:javascript
复制
if ($this->Auth->user('active') != '1') {
                $active = $this->Auth->user('active');
                $this->Session->destroy();
                if($active < 0)
                    throw new Exception(__('Invalid user or password. Try again'));

                throw new Exception(__('User blocked, contact your administrator'));
            } else {
                $_SESSION["user_login_errors"] = 0;
                //$this->redirect(array('controller'=>'users','action'=>'home'));
                $this->redirect($_SESSION['url_user']);
            }

消息通知(8):未定义索引: url_user

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-25 16:57:49

当然,只有我的域名网页。问题解决了,我的代码在其他存储库中运行得很好,复制了站点,然后又重新开始工作了。不管怎么说,接受你的建议

代码语言:javascript
复制
$this->Session->write

并阅读CakePHP。坦克斯!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24914774

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档