0

When I switched to the AWS Load balancer (multiple server), Session should be maintained unique. When I used to login my site the session lost and it redirected to the home page. So I have tried to store the session in DB using following code.

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

But it used to store the session data when admin used to logout. I have tried to configure cake session handler interface its fails.

How to haddle the session and cache in database.

1 Answers1

0

I don't know about the load balancer, but you can handle your sessions in serval ways, including using databases.

And this is the default configuration of CakePHP to use database for sessions.

First create this table :

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

Then, configure your sessions in app/core.php

Configure::write('Session', array(
    'database' => array(
            'cookie' => 'CAKEPHP',
            'timeout' => 240,
            'ini' => array(
                'session.use_trans_sid' => 0,
                'url_rewriter.tags' => '',
                'session.use_cookies' => 1,
                'session.cookie_path' => static::$path,
                'session.save_handler' => 'user',
                'session.serialize_handler' => 'php',
            ),
            'handler' => array(
                'engine' => 'DatabaseSession',
                'model' => 'Session'
            )
        )
));
beta-developper
  • 1,689
  • 1
  • 13
  • 24