Thanks Amit. I have tried your suggestion.
I used:
$this->Auth->Session->write($this->Auth->sessionKey . '.id', $this-
>User->getLastInsertID());
but it just became worse.
$this->Auth->user('id') doesn't return anything if I do that.
On Sep 24, 1:39 pm, "Amit Badkas" <[EMAIL PROTECTED]> wrote:
> 2008/9/24 mario <[EMAIL PROTECTED]>
>
>
>
> > Hello everyone,
>
> > Do anyone of you have an idea on how to automatically login
> > after signing-up using Auth Component?
>
> > I have tried like:
>
> > $this->User->create();
> > if ($this->User->save($this->data))
> > {
> > $this->Auth->Session->write($this->Auth->sessionKey, $this->User-
> > >getLastInsertID());
>
> - Try to debug session contents after this line of code to confirm that
> session data is correct
>
>
>
>
>
> > $this->Session->setFlash('You have successfully logged in.');
> > $this->redirect($this->Auth->redirect());
> > }
>
> > Now in my AppController, I have something like this:
>
> > <?php
> > class AppController extends Controller {
>
> > var $components = array('Auth');
> > var $helpers = array('Html', 'Form');
> > var $uses = array('User');
> > function beforeFilter()
> > {
> > $this->Auth->loginAction = array('controller' => 'users',
> > 'action'
> > => 'login');
> > $this->Auth->loginRedirect = array('controller' =>
> > 'mainpage',
> > 'action' => 'home');
> > $this->Auth->logoutRedirect = array('controller' =>
> > 'mainpage',
> > 'action' => 'home');
> > $this->Auth->allow('home','signup');
> > $this->Auth->authorize = 'controller';
> > //$this->Auth->userScope = array('User.confirmed' => '1');
> > $this->set('loggedIn', $this->Auth->user('id'));
>
> - As per your above code, it seems that you are putting user id directly in
> session using auth's session key, i.e., your need to do
> $this->Auth->Session->write($this->Auth->sessionKey . '.id',
> $this->User->getLastInsertID()); instead of
> $this->Auth->Session->write($this->Auth->sessionKey,
> $this->User->getLastInsertID());
>
>
>
>
>
> > $result = $this->User->findById($this->Auth->user('id'));
> > }
> > function isAuthorized()
> > {
> > return true;
> > }
> > }
> > ?>
>
> > This script is supposed to work but my problem is that $this->Auth-
> > >user('id') is only returning
> > the first digit of the number. For example, I have a userid: 53, now
> > when I will do $this->Auth->user('id'),
> > it only return "5" instead of "53".
>
> > Anyone of you can help me with this?
>
> > Thanks,
>
> > Mario
>
> --
> Amit
>
> http://amitrb.wordpress.com/http://coppermine-gallery.net/http://cheesecake-photoblog.org/http://www.sanisoft.com/blog/author/amitbadkas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---