Hi,
I try to use a session with slim (bryanjhv/slim-session), but after a redirect the session value does not exist. What is wrong here?:
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
use \Interop\Container\ContainerInterface as ContainerInterface;
class AppController extends FilterController
{
protected $ci;
protected $user_session;
//Constructor
public function __construct(ContainerInterface $ci)
{
$this->ci = $ci;
$this->user_session = new \SlimSession\Helper;
}
public function login($request, $response, $args)
{
$data = $request->getParsedBody();
$user = ORM::for_table('users')->where('email', $data['email'])->find_one();
if ($user !== false){
$this->user_session->set('user_id', $user->id);
//Printing this works!
//echo $this->user_session->user_id;
return $response->withRedirect('/app/list');
}
}
public function list($request, $response, $args)
{
//This don't work :-(
echo $this->user_session->user_id;
}
...
Thank you so much