I am storing random stuff in my CI session such as a userID for example, and I have crawled up and down my code looking for the error, to then end up doing the sane thing and doing a var_dump / print_r on my session data.
So heres the thing. I do the print_r and i see the userID correctly in this case 21. But if I go one line directly below that print_r and do echo $this->session->userdata('userID'); my result is 2121 instead of 21, which is messing things all sorts of up for me, and I can’t find anything anywhere that mentions a similar problem so I am hoping someone here can set me straight.
edit to show “code”
print_r($this->session->userdata);
echo $this->session->userdata('userID');
which yields this result…
Array ( [userID] => 21 ) 21
but if I do this..
//print_r($this->session->userdata);
echo $this->session->userdata('userID');
i get this as a result
2121
hopefully this clears up the confusion some..
it seems like you’re outputting 21 someplace else
which is why you get
2121andArray ( [userID] => 21 ) 21do an
exit();right after
echo $this->session->userdata('userID');and you’ll see exactly what is stored there,
also
var_dump()is a good idea.