Level 104
You cannot use the session in a Controller constructor - it is not available yet. I would suggest using a custom middleware to check the session and redirect the request if required
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i am using Global Session Helper in controller but i can't get values from it please see code below /** public $lang;
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$lang = session("language");
$this->redirectTo = '/'.$lang.'/profile';
dd($this->redirectTo);
$this->middleware('guest');
}
the out put ://profile **/ please help me
You cannot use the session in a Controller constructor - it is not available yet. I would suggest using a custom middleware to check the session and redirect the request if required
Please or to participate in this conversation.