0
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
in Session
, in my case is $_SESSION['user_id'] = 2
. After the page is rendered, there is a download button, in case a href
redirecting to the method teste()
, but when opening this method, my session does not recognize the user_id
and an error is generated: Notice: Undefined index: user_id
.
There’s something strange too. Locally this code works, but on the server (when hosted) it does not work.
In your PHP.INI display_errors is set to ON?
– Allan Andrade