CodeIgniter Forums

Full Version: Retrive data from session.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I getting NULL Registration id from session.

But when i check
Code:
var_dump( $this->session->userdata['logged_in']);die;

Result:
array (size=3)
 'registration_id ' => string '1' (length=1)
 'email' => string '[email protected]' (length=20)
 'name' => string 'Ahmed' (length=12)

When i am getting registration id from session, its null

Code:
$registration_id = $this->session->userdata['logged_in']['registration_id'];
var_dump($registration_id);die;

Result:
null

Help me out Thanks.
That is very strange. Is there anything happening between the two var_dumps besides assigning value to $registration_id? Try something like this and see what happens.
PHP Code:
$registration_id $this->session->userdata['logged_in']['registration_id'];
var_dump($this->session->userdata['logged_in']['registration_id']);
var_dump($registration_id);
die; 

I'm stumped if you still get NULL. If you don't get NULL, it probably means you are accidentally modifying the session data somewhere before assigning the value to $registration_id.
(03-11-2015, 06:07 AM)RobertSF Wrote: [ -> ]That is very strange. Is there anything happening between the two var_dumps besides assigning value to $registration_id? Try something like this and see what happens.


PHP Code:
$registration_id $this->session->userdata['logged_in']['registration_id'];
var_dump($this->session->userdata['logged_in']['registration_id']);
var_dump($registration_id);
die; 

I'm stumped if you still get NULL. If you don't get NULL, it probably means you are accidentally modifying the session data somewhere before assigning the value to $registration_id.

I got my error Here:
Result:
array (size=3)
'registration_id ' => string '1' (length=1)
'email' => string '[email protected]' (length=20)
'name' => string 'Ahmed' (length=12)

1st line after registration_id and before single inverted comma containing a wide space. Tongue
AND i am using netbeans.
Thanks.
Glad you found it! I didn't notice that at first either. Smile