Thursday, June 25, 2009

Re: retrieve profile id from session

There are a few ways you could get that,

just for the hell of it, when you say you used:
$user['Profile']['id'], was that in the User's views or the Profile's
views. "$user" will only be available to your views to which were
passed the variable from the controller $this->set(compact('user'));

hopefully it was just that. If not, you could set the user info in
either a cookie or session variable, I personally find it a better
approach to set it in a Session variable. Therefore, you will have to
set it up in your authentication component. As soon as the user logs
in, do:

$this->Session->write("variable_name", "value");

So you would do something like:

$user_info = $this->User->find('first', array('conditions'=>array
('id'=>$this->data['User']['id'])));
$this->Session->write('user_info', $user_info);

then, to read this from your view...

$this->Session->read('user_info');

Hope this helps,
Good Luck

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: