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

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

问题描述

我有一个我正在处理的 CakePHP 2.x 站点,它在本地按预期执行.登录有效,会话 Flash 消息有效,等等.当我将代码推送到我的登台/生产服务器时,它就崩溃了.

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.

登录不再有效,没有出现会话 Flash 消息,一些应该重定向到/user/login 的控制器操作没有显示任何内容(空文档)等.

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.

我不知道问题是什么.根据我遇到的问题和我所做的一些搜索,我相信我已经排除了在纯代码 PHP 文件(控制器)中关闭 ?> 后出现空格等问题.我正在使用数据库会话,我看到在本地实例的数据库中创建了会话记录,但在远程登台/生产实例上没有.

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天全站免登陆