Session variables in a model

2007-03-30 Thread fr3nch13

Is there a way to access the session component in a model?

I store a user's information in the session [$this-Session-
read('User')] and when the user edit's their information, i want it
to be able to update the session. I would do it in the controller, but
there are 3 different ways to edit a user's information (long story..
had to be like this.) Because of this, i was trying to use the model's
afterSave() method to update the session, but i am getting an error
saying this-Session isn't available in the model. Anyone have any
ideas on how to do this?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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
-~--~~~~--~~--~--~---



Re: Session variables in a model

2007-03-30 Thread Piotr Barszczewski

You clould pass the reference of the Session component to the model's
function.
Controller:
$this-myModel-myModelMethod( $this-Session );

Model:
function myModelMethod( $sessionComponent ){
$sessionComponent-read( 'session.var' );
}

It should work, theoretically

On 30 Mar, 17:07, fr3nch13 [EMAIL PROTECTED] wrote:
 Is there a way to access the session component in a model?

 I store a user's information in the session [$this-Session-read('User')] 
 and when the user edit's their information, i want it

 to be able to update the session. I would do it in the controller, but
 there are 3 different ways to edit a user's information (long story..
 had to be like this.) Because of this, i was trying to use the model's
 afterSave() method to update the session, but i am getting an error
 saying this-Session isn't available in the model. Anyone have any
 ideas on how to do this?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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
-~--~~~~--~~--~--~---



RE: Session variables in a model

2007-03-30 Thread Peter Brenner

Session information is not available in the model. 
I had a similar requirement where I needed to get user information out of
the session for auditing purposes when records are updated.  I solved the
problem by implementing an Observable Model.  Have a look at this article
for information on how to implement.

http://bakery.cakephp.org/articles/view/96

-Original Message-
On 30 Mar, 17:07, fr3nch13 [EMAIL PROTECTED] wrote:
 Is there a way to access the session component in a model?

 I store a user's information in the session [$this-Session-read('User')]
and when the user edit's their information, i want it

 to be able to update the session. I would do it in the controller, but
 there are 3 different ways to edit a user's information (long story..
 had to be like this.) Because of this, i was trying to use the model's
 afterSave() method to update the session, but i am getting an error
 saying this-Session isn't available in the model. Anyone have any
 ideas on how to do this?




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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
-~--~~~~--~~--~--~---