Welcome Guest, Not a member yet? Register   Sign In
Session in CI 4 is not working accross the controller
#1

(This post was last modified: 08-15-2020, 07:42 AM by jreklund.)

Home.php
PHP Code:
<?php namespace App\Controllers;
use 
Config\Services;
class 
Home extends BaseController
{      public $session;
        function __construct()
        
            
            
if (session_status() == PHP_SESSION_NONE)
            {
                $this->session Services::session();
            }
        }
public function 
index()
{
            $user = array(
                'one','two'
            );
                    
            $this
->session->set('usr',$user);
           return view('welcome_message');
}

//--------------------------------------------------------------------




TestSession.php
PHP Code:
<?php namespace App\Controllers;
use 
Config\Services;
class 
TestSession extends BaseController
{      public $session;
        function __construct()
        
           
            
if (session_status() == PHP_SESSION_NONE)
            {
                $this->session Services::session();
            }
        }
public function 
index()
{
            
            
echo '<pre>';
            print_r($this->session->user); // Not printing the the session data assigned in Home.php PLease help what should i do.?
}

//--------------------------------------------------------------------


Reply


Messages In This Thread
Session in CI 4 is not working accross the controller - by samiul1978 - 08-15-2020, 05:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB