how do i access the session variables in the pages in agile toolkit. i am using $this->getUser() but it is not working
1 Answers
In agile toolkit each object can register session variables. This is done to allow you to have multiple objects work indecently and not conflict.
Basic functions are:
$o->memorize('handle',123);
$o->recall('handle');
$o->forget('handle');
If you intentionally wish to share data, then you can use
$o->api->memorize('my_global_var',123);
Since you mentioned about User ID, then authorization object handles its own variables. Similarly it uses memorize/recall to manipulate auth data settings, but you can get the information like this:
$user_id = $o->api->auth->get('id');
When $auth->check() is performed, all fields returning by the query are saved. If you wish to add more fields, then perform
$auth->dq->field('extrainfo');
and this field will be selected by DSQL and stored in session too for further retrieval by $auth->get('extrainfo')
To create getUser function, typically you would define this in API:
function getUser(){
return $this->add('Model_User')->loadData($this->auth->get('id'));
}
and use $this->api->getUser()
to retrieve the data.

- 10,606
- 4
- 50
- 70
-
Dont forget to mark Roman's answer as the right one by clicking the tick in the left margin – Trevor North Sep 18 '11 at 23:26