views:

36

answers:

2

So, I've tried many many things, but still always end up with Cookies that have the duration set to "Session" when looked at with Developers Tools in Google Chrome. Here are my current settings:

core.php:

Configure::write('Session.cookie', 'session');
Configure::write('Session.timeout', '3600');
Configure::write('Session.start', true);
Configure::write('Security.level', 'high');

users_controller.php

$this->Cookie->write('xHi1PeWmAw', $user_record['User']['id']);

I tried changing the Security.level, the Session.timeout, using $this->Cookie->time = 3600; and combining all that, but I can't seem to be changing that duration. Also I tried with short and long durations, given that I would ideally for this cookie to last as long as possible. Can you please tell me what I am doing wrong?

A: 

Though I cannot guarantee this will fix your issue I can explain how to properly configure the sessions.

First you set your Security.timeout variable. This represents a timeout value in seconds, but this does not equal your sessions expiration time. This number is multiplied by a constant value depending on the setting of your Security.level variable.

'high' = x 10, 'medium' = x 100, 'low' = x 300,

This is what gives you your expiration time. For example, if you have a Session.timeout of 30, and a Security.level of low, your sessions will expire in 30*300 seconds, or 150 minutes.

Slruh
well I did get this far, but what I don't get is "in which case my cookie will no longer have a real duration but become a 'session' cookie"... Thanks for trying though.
Damien
A: 

If you you're using cookies as a session then it's time is set to 0. Which means it is set to expire when the browser closes. You could try to change this number in the controller as shown in the code below. See if that makes a difference. I have not tested this, but it is worth a shot.

var $components = array('Cookie');
function beforeFilter() {
   $this->Cookie->name = 'baker_id';
   $this->Cookie->time = 3600; // or '1 hour' //IF 0 THIS IS A SESSION COOKIE
   $this->Cookie->domain = 'example.com';
   $this->Cookie->secure = true; //i.e. only sent if using secure HTTPS
   $this->Cookie->key = 'qSI232qs*&sXOw!';
}
Slruh