public function index(){
session_start();
$_SESSION['user_id'] = 2;
// Na minha página é impressa o valor "2"
echo $_SESSION['user_id']."<br/>";
$this->view->render("dashboard/dashboard-2");
}
public function teste(){
session_start();
echo $_SESSION['user_id']."<br/>";
//Notice: Undefined index: user_id
}
// My HTML
<a href="<?php echo URL ?>dashboard/teste" class="btn btn-primary">TESTE</a>
Before rendering the page, I save a id
on Session
, in my case it is $_SESSION['user_id'] = 2
. After the page is rendered, there is a download button, in this case a href
that redirects to the teste()
method, however when opening this method, my session does not recognize user_id
and an error is generated: Notice: Undefined index: user_id
.
There is a strange thing as well. Locally this code works, but on the server (when being hosted) it does not work.