How can I define a global variable so that my current_user method can work, someday I want it, all I just need to do is check if there is a current user, my sample code below
if (isset($_SESSION['company_id'])) {
$current_user = Companies::find($_SESSION['company_id']);
}
else
{
$current_company = null;
}
how can I use the current user method when I want, without passing it to the method app->render(), as in my header.html
{% if current_user %}
hi {{current_user.name}}
{% endif %}
source
share