On Mar 6, 8:56 pm, rtconner <[EMAIL PROTECTED]> wrote:
> global $SESSION;
> $SESSION = $this->Session;
>
> screw this not getting at the session from the model crap, there are
> exceptions to every rule and this is one of them
>
rtconner:
OMG u r teh N00Bzorz!!1one!
Novice Programmer:
There are two right ways of doing this. One is to make the session a
formal part of your domain model, i.e. model it. This allows it to
interact with other models at the model level. The model, like the
view, should never directly query a tier outside its own. The other
is to use a callback to notify the model of the user's state.
Assuming you are following proper convention, this can be handled
across your entire application in one fell swoop:
class AppController extends Controller {
var $components = array("Auth");
function beforeFilter() {
$this->{$this->modelClass}->setUserState($this->Auth->user());
}
}
class AppModel extends Model {
function setUserState($user) {
// Handle authentication data/set local variables in prep for
validation
}
}
Hope that helps. If you're not able to get it to work, reply to this
thread and myself or someone else knowledgeable in proper OO/MVC
design will respond.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---