CakePHP 2.x会话在本地开发和生产之间不一致 [英] CakePHP 2.x sessions behaving inconsistently between local dev and production

查看:98
本文介绍了CakePHP 2.x会话在本地开发和生产之间不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CakePHP 2.x网站,我的工作,在本地执行。

I have a CakePHP 2.x site I'm working on which performs as intended locally. Login works, session flash messages work, etc. When I push the code to my staging/prod server it's breaking.

登录不再工作,没有会话刷新消息出现,一些控制器动作,应该重定向到/用户/登录没有显示任何东西(空文档)等。

Logins no longer work, no session flash messages appear, some controller actions that should be redirecting to /user/login are displaying nothing (empty document), etc.

我有些什么问题。基于我遇到的问题和一些搜索我做了我相信我已经排除了问题,例如空格后关闭?> 文件(控制器)。我正在使用数据库会话,我看到会话记录正在我的本地实例的数据库中创建,而不是在远程登台/ prod实例上。

I'm at a loss as to what the problem would be. Based on the issues I'm experiencing and some searching I've done I believe I've ruled out problems like whitespace after the closing ?> in a code-only PHP file (controllers). I'm using DB sessions, and I see session records being created in the DB on my local instance, but not on the remote staging/prod instance.

任何帮助非常感谢。感谢。

Any assistance would be much appreciated. Thanks.

推荐答案

我经常遇到的一个建议是确保在关闭PHP标签后没有空格(或优选地实际上不具有结束的PHP标签)。检查我的所有文件显示是这样的情况。不过,不管怎样,我设法在 AppController.php 中打开PHP标记之前放置一个换行符,这是问题。我向任何浪费时间的人道歉。我只是希望这可以帮助未来的人笨拙地犯同样的错误。

One of the recommendations I came across frequently was to ensure that there was no whitespace after the closing PHP tag in a code-only file (or preferably to not actually have a closing PHP tag). Checking all my files showed that to be the case. Somehow, however, I managed to put a single line break before the opening PHP tag in AppController.php and that was the issue. My apologies to anyone who wasted time on this. I just hope this helps someone in the future who clumsily makes the same mistake.

这篇关于CakePHP 2.x会话在本地开发和生产之间不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆