Cakephp会话错误在现场网站 [英] Cakephp Session error on live site

查看:102
本文介绍了Cakephp会话错误在现场网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在cakephp中使用会话组件时遇到问题。
他们在整个网站,当在不同的服务器上的开发网站工作正常。

I am having issues with using the session component in cakephp. They worked fine throughout the site, when on a dev site on a different server.

在新服务器上上传最终版本后,似乎会话将无法在某些控制器中启动。只有两个控制器是这种情况发生,但似乎没有什么不同的在这些控制器 - 除了可能的事实,只有这两个控制器使用自定义文件上传器组件。已尝试停用此功能,但没有任何更改。

After uploading the final version on the new server, it seems that the session will not start in certain controllers. Only on two controllers is this happening, but nothing seems to be done differently on these controllers - except possibly the fact that only these two controllers are using a custom file uploader component. Have tried disabling this and nothing changed.

网站是一个电子商务系统,问题主要发生在尝试添加一个项目到篮子,会话。这个会话保持空白,而在开发网站工作了一个魅力。

The website is an ecommerce system, with the problems mainly occuring when trying to add an item to the basket, which is stored in a session. this session is remaining blank, whereas on the dev site worked a charm.

我也使用auth组件登录/注销,虽然这两个区域不需要登录到函数,它们会导致它切换到注销每当它们被加载 - 并且然后当访问站点的任何其他区域时,它自身切换回。 auth和会话组件已加载到appcontroller中。

I am also using the auth component to login/logout, and although these 2 areas are not required to be logged in to function, they cause it to switch to logged out whenever they are loaded - and this then switches back by itself when any other areas of the site are accessed. The auth and session components are loaded in the appcontroller.

谢谢!

推荐答案

我之前有一个类似的问题,对我来说,我和@starlocke有同样的印象,需要开始。在检查未定义 $ _ SESSION 之后,我使用 session_start()命令代替Cake的Session组件。例如:

I've had a similar problem before now, and for me I was under the same impression as @starlocke that something needed kick starting. Instead of using Cake's Session component I used the session_start() command, after checking that $_SESSION was not defined. For example:

if(!isset($_SESSION)) session_start();

这放在AppController类的beforeFilter()方法中。

This was placed inside the beforeFilter() method of the AppController class.

我还有一个问题,它说它无法启动会话,因为已经输出到服务器,这是解决了我通过删除任何关闭 ?> 控制器内的标记,因为这些不是php所需要的,并停止任何不需要的输出发送到浏览器,就像这种情况。

I then also had a problem where it was saying it couldn't start the session because of there already being output to the server, this was solved for me by deleting any closing ?> tags inside controllers, as these aren't required by php and stop any unneeded output being sent to the browser like in this case.

进一步阅读php关闭标签:

Further reading on php closing tags:

  • Why I don’t use closing PHP tags
  • PHP closing tag

这篇关于Cakephp会话错误在现场网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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