Sorry I meant setState. I can’t seem to edit the title to fix.
In UserIdentity.php I have the following:
public function authenticate()
{
...
$adminUsers=array();
foreach ($admins as $u) {
array_push($adminUsers,$u['username']);
}
$this->setState('memberId', $user->memberId);
$this->setState('adminusers', &$adminUsers);
$y=$this->getState('adminusers');
$x=print_r($y,true);
fwrite($fh,"Data is ".$x."\n");
The output looks fine. The array contains the correct 3 entries which are
strings.
The controller class looks like:
class FcarcMembersController extends Controller
{
...
public function accessRules()
{
$user=Yii::app()->user;
$adminusers = $user->getState('adminusers');
$m = $user->getState('memberId');
$myFile = "/tmp/artestFile.txt";
$fh = fopen($myFile, 'w');
$x=print_r($adminusers);
fwrite($fh," A Data is ".$x."\n");
fwrite($fh," R Data is ".$m."\n");
However the output from these write statements show the memberId is OK but the
output from the print_r is "1". It seems that the array was only temporarily
stored in the setState while a string is permanent.
I’m guessing I’m doing something foolish, but I can’t figure out what. Suggestions? The api documentation for setState is rather sparse. I didn’t know if I needed to dereference the $adminUsers array or not, but I tried it both ways with identical results.
Thanks,
Jim.