Cakephp default session is saved in the configuration /etc/php.ini,
this was defined in app/config/core.php:
Configure::write('Session.save', 'php');
most likely it looks as below:
session.save_handler = files
session.save_path = "/var/lib/php/session"
this kind of file based session/cache will not work correctly under load balancer/multi web app servers.
the solution is using database or Memcache.
For using Memcache, we should change the config to:
Configure::write('Session.save', 'cache');
and enable the Memcache engine in core.php
Cache::config('default', array(
'engine' => 'Memcache', //[required]
'duration'=> 3600, //[optional]
'probability'=> 100, //[optional]
'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
'servers' => array(
'127.0.0.1:11211' // localhost, default port 11211
), //[optional]
'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
));
we can check if the memcache has been installed and running by phpinfo()
and ps -ef|grep memcache
but unfortunately, even you installed/configured memcache and cakephp well both, this will still not work.
you will lose sessions when navigating pages.
if you enable debug mode, you will see errors in the bottom of the page:
Fatal error: Class 'Debugger' not found in
/var/www/cake/libs/debugger.php on line 252 Warning: Invalid
callback CakeSession::__close, class 'CakeSession' not found in
Unknown on line 0
to solve this problem, you have to apply below patch:
http://cakephp.lighthouseapp.com/projects/42648/tickets/825-debuggerphp-error-when-session-set-to-cache
--- public_html/cake/libs/model/datasources/datasource.php.orig 2010-11-09 15:56:06.897482341 -0600
+++ public_html/cake/libs/model/datasources/datasource.php 2010-11-09 15:57:10.341327526 -0600
@@ -521,6 +521,12 @@ class DataSource extends Object {
$this->rollback($null);
}
if ($this->connected) {
+ if ((Configure::read('Session.save') == 'cache' ||
+ Configure::read('Session.save') == 'database')
+ && function_exists('session_write_close')) {
+ session_write_close();
+ }
+
$this->close();
}
}
分享到:
相关推荐
cakephp--使用_CakePHP_的_Session_和_Request_Handler_组件
没分了,下载不了。挣点分。 有三个文件,分别为: memcache简介、安装 and in cakephp。
You'll learn about unit testing and how to implement it in CakePHP. This approach to coding leads to better code, better applications, and better programming habits. With this knowledge your ...
You’ll learn about unit testing and how to implement it in CakePHP. This approach to coding leads to better code, better applications, and better programming habits. With this knowledge your ...
Target beginners of CakePHP or web frameworks in general as well as experienced developers with limited exposure to CakePHP. A secondary audience may include developers undecided on adopting CakePHP ...
You'll learn about unit testing and how to implement it in CakePHP. This approach to coding leads to better code, better applications, and better programming habits. With this knowledge your ...
afterFind) in behaviors, while the fourth recipe shows how to use behaviors to add additional field values when a save operation is being undertaken. The last two recipes in this chapter give ...
解压密码在:http://www.pin5i.com/showtopic-building-php-applications-with-symfony-cakephp-zend-framework.html
From routing to authentication, the model layer and the events system, as well as views and unit testing, you'll learn how to handle the ins and outs of developments using CakePHP. With fast paced ...
There are two main ways to get a fresh copy of CakePHP. You can either download an archive copy (zip/tar.gz/tar.bz2) from the main website, or check out the code from the git repository. To download ...
本文实例讲述了CakePHP框架Session设置方法。分享给大家供大家参考,具体如下: CakePHP Session 存储选项 CakePHP提供给用户了3种Session数据保存方式: 1. CakePHP安装目下的临时文件; 2. 采用PHP的默认机制; 3. ...
在cakephp.org站点的Sites in the wild页面可以看到当前使用CakePHP框架的网站列表。 CakePHP 是一个运用了诸如ActiveRecord、Association Data Mapping、Front Controller和MVC等著名设计模式的快速开发框架。该...
在cakephp.org站点的Sites in the wild页面可以看到当前使用CakePHP框架的网站列表。CakePHP 是一个运用了诸如ActiveRecord、Association Data Mapping、Front Controller和MVC等著名设计模式的快速开发框架。该项目...
在cakephp.org站点的Sites in the wild页面可以看到当前使用CakePHP框架的网站列表。 CakePHP 是一个运用了诸如ActiveRecord、Association Data Mapping、Front Controller和MVC等著名设计模式的快速开发框架。该...
打包下载,里面有CakePHP的框架源码,下载后可直接使用,版本是1.1的,稳定版;CakePHP的分页组件源码;CakePHP的中文及英文教程,CHM格式;CakePHP的中文打印版教程,WORD格式,下载后可直接打印,方便的;CakePHP...
Cakephp 2.x的Redis会话数据源-Croogo 1.5 一个简单的Redis会话存储,具有额外的功能,可以保留已登录用户的“映射”。 然后,身份验证对象可以使用此映射来防止同一用户的多次登录。 要求: wddx模块已激活cakephp>...
cakephp 框架 cakephp 框架 cakephp 框架 cakephp 框架 cakephp 框架
打包下载,里面有CakePHP的框架源码,下载后可直接使用,版本是1.1的,稳定版;CakePHP的分页组件源码;CakePHP的中文及英文教程,CHM格式;CakePHP的中文打印版教程,WORD格式,下载后可直接打印,方便的;CakePHP...
As the first book to come out on CakePHP, there was a lot of pressure on this title to be really strong. On the whole, it has pretty good coverage of the topic, but the flow of the title is undermined...
CakePHP 3.4 开发手册文档 CakePHP Cookbook Documentation Release 3.4