Thanks for the reply. I'm learning :) On Feb 17, 12:24 am, Miles J <[email protected]> wrote: > Its because you are redirecting before setting the data. > > Try this, assuming you are using the Auth component. > > function login() { > $this->set('error', false); > > if ($this->Auth->user()) { > $this->Session->setFlash('You are logged in!'); > $this->Session->write('user.email', > $this->Auth->user('email')); > $this->redirect('/', null, false); > } > > } > > But at that point, you can use use this everywhere if a user is logged > in. > > $this->Auth->user('email') > > On Feb 16, 3:54 pm, barricades <[email protected]> wrote: > > > Hey there, I have a login function in which I had added some code to > > write a users email to the session. > > > For some reason when I used this code: > > function login() { > > $this->set('error', false); > > //see if the user is already logged in > > /*if ($this->Session->read('Auth.User')) { > > $this->Session->setFlash('You are logged in!'); > > $this->redirect('/', null, false); > > } */ > > if($this->data){ > > $this->Session->write('user.email', > > $this->data['User']['email']); > > } > > } > > > It wouldn't write the email to session (it does the check to see if > > the user is logged in ok), but when I used the following, it did. I > > don't understand, whats the difference? Can you only have one if > > statement in the login function or something? > > > /*function login(){ > > $this->set('error', false); > > if($this->data){ > > $this->Session->write('user.email', $this->data['User'] > > ['email']); > > } > > }*/
-- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
