On Thu, Oct 9, 2008 at 10:41 AM, Liebermann, Anja Carolin <
[EMAIL PROTECTED]> wrote:

>
> Hi all,
>
> Now that I have placed a function in my model rather than in my
> controller to avoid requestAction I have a new problem:
>
> The function gets data from my session.
> In the controller the following works:
>        $user = $this->Session->read('User');
>
> When I place this code in my model method I get the error message:
> Undefined variable: Session [APP\models\text.php, line 95]
>
> So I tried to avoid this by using the function like that:
>        App::import('Model', 'Session');
>        $Session = new Session()
>        $user = $Session->read('User');
>
> This causes:
> Fatal error: Class 'Session' not found in...
>
> Questions: Is it possible to use Session data in my model? If yes which
> syntax is correct?
>

Some people will probably jump in and say you shouldn't be reading session
data from the model (breaks MVC, etc). Maybe you can send it as an argument
to the model function?

If you insist, I think you want:

App::import('Model', 'CakeSession');
$session = new CakeSession();

.. but I'm not 100% sure.

- Gonzalo

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to