I came accross a problem while developing a user authentication system for an elegent way to store information to the session. I came up with this function …
Throw that in your app_controller.php file and it takes argguments in the same form that Cake pulls them out of the database in(Including the nested arrays for associations) and saves them in the form of Session->Model->Field = Value. For example if I want to get the currently logged in users ID, $this->Session->read(‘User.id’); This function could probably be expanded on to allow for non-associated arrays, i.e. a call for just one entry that does not return any associations will be a one level array, like Location->Field->Value as opposed to Location->0->Field->Value. Perhaps in my free time =)
Popularity: 1% [?]
0 Responses to “Saving To Session In Cake”