I've been trying to implement a "remember me" option to my login screen for the last hours, with no success. Can someone give me a little help? =D
I'm using cakephp 2.3.9 in a apache2/mysql 5.5/ubuntu 12.10 server. In "login()" method, inside my users controller, I've added the code:
if ($this->Auth->login()) {
if($this->request->data('Usuario.remember')==="1"){
CakeSession::write('Session.timeout', '144000');//100 dias
}
return $this->redirect($this->Auth->redirect());
}
I was hoping it would make that particular user session bigger than usual, but it seems that it was applied to all users. I'm using cakephp's default auth component. Can someone show me what I'm doing wrong and what should I do? Thanks in advance ;]
I'm unaware of any to do this with the way you're approaching it. PHP session timeout lengths are a server-wide setting defined in your PHP.ini under session.gc_maxlifetime.
The way I personally would approach this would be to overwrite the session handler you're using, and rather than using the PHPSESSID cookie, create yourself your own cookie where you have control over the cookie expiry time. This could then hold a custom Session ID which your overwritten session handler could then pick up and use to authenticate the user.
CakePHP isn't something I'm too familiar with so I can't give you too much advice in the integration.