Tuesday, January 17, 2012

Re: AuthComponent using Cookies

All you need is this documentation page

http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#creating-custom-authentication-objects

Simple/straightforward way how to do what you want is this code in
place:

http://bin.cakephp.org/view/1497928407#modify

configured for usage in AppController like this:

public $components = array(
'Cookie' => array(
'name' => 'common',
'time' => '+14 days'),
'Auth' => array(
'authenticate' => array(
'Cookie',
'Form'),
...

and these 3 lines in your login() method, when user is successfully
authenticated by FormAuthenticate adapter:

$username = $this->request->data['User']['username'];
$password = $this->request->data['User']['password'];
$this->Cookie->write('remember', compact('username', 'password'),
true, '+2 weeks');

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate