Hi,
In IndexController, signin action -- where session gets created and sets some sessiom variables. Defined an hyperlink in signin.phtml, that redirects to welcome action in Index Controller. Trying to get session variables in welcome action. But, no luck and its not working.
Please, find the source code link below: TempApp
//index.php
$di->setShared(
'session',
function () {
ini_set('session.gc_maxlifetime', 3600);
session_set_cookie_params(3600);
$session = new Session(
[
"uniqueId" => "my-app-1",
]
);
$session->start();
return $session;
}
);
//indexcontroller.php
public function signinAction(){
session_start([
'cookie_lifetime' => 86400,
]);
echo "SignIn Action";
$this->session->set('user-name', 'kkk');
$_SESSION['user'] = 'green';
}
public function welcomeAction(){
// Check if the variable is defined
if ($this->session->has('user-name')) {
// Retrieve its value
$name = $this->session->get('user-name');
echo $name;
}
var_dump($this->session);
var_dump($_SESSION);
}
Thanks Karthik K