post #1 of 1
Thread Starter 
So i've been trying to wrap my head around sessions in CakePHP and can't figure it out at all. I'm trying to save a session that is a variable containing an array.
Code:
$user = array('User' => array(
     'username' => 'someone'
));

$this->Session->write('User', $user);

I have that saved and I can access it in my view by
Code:
debug($this->Session->read('User'));

However I cannot access the single 'username' field in the array. According to the CakePHP documentation I can just
Code:
echo $this->Session->read('User.username')

However that doesn't print out anything at all. Any ideas?

Thanks

Edit:

I figured it out. If anyone is curious I had to put
Code:
echo $this->Session->read('User.User.username')

Edited by the_dude - 3/13/13 at 2:23pm
My System
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 @ Stock Asus P6T ATI HD5870 OCZ 6GB 1333mhz 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Caviar Black 640GB LG DVD Drive Cm Hyper 212+ 
CoolingOSMonitorPower
Arctic Cooling Accelero Twin Turbo II Windows 7 64bit ASUS VW246H Corsair HX850 
Case
CM 690 II Adavanced 
  hide details  
Reply
My System
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 @ Stock Asus P6T ATI HD5870 OCZ 6GB 1333mhz 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Caviar Black 640GB LG DVD Drive Cm Hyper 212+ 
CoolingOSMonitorPower
Arctic Cooling Accelero Twin Turbo II Windows 7 64bit ASUS VW246H Corsair HX850 
Case
CM 690 II Adavanced 
  hide details  
Reply