Looking at your code, I would have to say that it is not recommended to add
models at the AppController level. Your code is just asking to be made a
component :)
Something like app/controllers/components/remember_me.php:
<?php
class RememberMeComponent extends Object
{
var $components = array('Session', 'Cookie');
var $uses = array('User');
function remember()
{
if(!$this->Session->check('User') &&
$this->Cookie->check('login'))
{
$cookie_arr = $this->cookie->read('login');
$someone = $this->User->findByEmail($cookie_arr[0]);
if($someone['User']['password'] == $cookie_arr[1])
{
$this->Session->write('User',
$someone['User']);
}
}
}
}
?>
Then on your AppController you add RememberMe as a component, and on your
beforeFilter() you do:
$this->RememberMe->remember();
-MI
---------------------------------------------------------------------------
Remember, smart coders answer ten questions for every question they ask.
So be smart, be cool, and share your knowledge.
BAKE ON!
-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de Walker Hamilton
Enviado el: Lunes, 04 de Diciembre de 2006 01:22 p.m.
Para: Cake PHP
Asunto: Re: How do I use cookies in cakePHP
Hi, I also used Rossoft's cookie component as well.
I also wanted to easily let users log in (no matter which page they
enter on). So here's my attempt to make that happen:
http://walkerhamilton.com/437/cakephp-remember-me
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---