Setting Cakephp sessions to database

I just migrated my app from cakephp1.3 to cakephp2.0. I have problem configuring session to database.

I changed session configuration in core.php

Configure::write('Session', array(
    'defaults' => 'database',
        'handler' => array(
        'model' => 'Session'
        )
));

I have a db table a sessions. Is there anything I missed. When I write sessions on login and redirects fine and I can read session variable fine. But on page refresh, the session is deleted.

Answers


From my understanding, you are trying to use Cake's default database session handling, and you are not using a custom handler model, if so:

Set these configuration options for Cake to use the database sessions in app/config/core.php:

Configure::write('Session', array(
    'defaults' => 'database'
));

Make sure you run this for the database you will be using to create the proper table, as Cake will store the sessions there:

CREATE TABLE cake_sessions (
  id varchar(255) NOT NULL default '',
  data text,
  expires int(11) default NULL,
  PRIMARY KEY  (id)
);

Need Your Help

SQL: not a single group function … not a GROUP BY expression

sql oracle oracle11g aggregate-functions min

I have a number of tables detailing a shop's customers and sales, etc.

How to handle multiple search condition of xpath in python Element Tree

python xpath elementtree

I want to extract some elements from a xml file by multiple search condition using Python(2.7.5) ElementTree.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.