By using all_userdata() function you can print all session data in CodeIgniter. 
The below example demonstrates how to print all session data in CodeIgniter.
Example:

Home_Controller.php

<?php

header('Access-Control-Allow-Origin: *');
defined('BASEPATH') OR exit('No direct script access allowed');

class Home_Controller extends CI_Controller {

    public $data;
    public $user_id;

    function __construct() {
        parent::__construct();
    }

    public function index() {
        $user_id = 20;
        $res = $this->home_m->get_user_by_id($user_id);
        $sessiondata = array(
            'uid' => $res->uid,
            'username' => $res->username,
            'email' => $res->email,
            'usertype' => $res->usertype,
            'name' => $res->name,
            'profile_pic' => $res->profile_pic,
            'is_verified' => $res->is_verified,
            'color_code' => $res->color_code,
            'profile_verified' => $res->profile_verified,
            'isloggedin' => true);
        $this->session->set_userdata($sessiondata);
        print_r($this->session->all_userdata());
    }
}
?>

In the above example, we have get the details from the database and set it into session, and checked whether all the data is stored in session or not using printing all the data.

So you can check the all session data by using below methods:


print_r($this->session->all_userdata());

OR

print_r($this->session->userdata); 

Written by
Check out this Author's contributed articles.
If you like Tutorialsmint and would like to contribute, you can also write an article using Write an Article. See your article appearing on the Tutorialsmint main page and help other programmers to enhance their knowledge.

Comments(0)

RECENT TUTORIALS
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Edit Post
Add Reply