codeigniter中的会话问题

I am using codeigniter sessions. When my user logged in session successfully store the data record that i want to store in it and also remove the particular record on the stage of logout. It works properly.

But the problem is when i print the all the data stored in session with the use of following code

$this->session->all_userdata();

It display two records one is stored during logged in and another is stored by default. If i check the same thing before logged in it show me a single record with some default values in session array. Like this:

Array ( [session_id] => c59388c6a8 [ip_address] => 230.230.230.230 [user_agent] => Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0 [last_activity] => 1420158230 [user_data] => [last_rec] => stdClass Object ( [id] => 30 [first_name] => Daniel [last_name] => james [user_email] => d@gmail.com [score] => 449 [picture] => images/301399704385.jpg [country] => USA [city] => na [userid] => d430 ) ) 

I dont know why session class return this same object with my session array variables.

At the point of logout, unset all the userdata you have given individually and then destroy the session.

Use it like this.

$this->session->unset_userdata('id'); 
$this->session->unset_userdata('first_name');
$this->session->unset_userdata('last_name'); 

.....

and so on.

Then you use below code to destroy the session.

$this->session->sess_destroy();

After that check and see if user data still exists.

Hope this helps.