Home.php
TestSession.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.?
}
//--------------------------------------------------------------------
}