Use the Session class in the root namespace.
I.e.
public function createSession($username)
{
\Session::put('username', $username); // Note the backslash to indicate the root class path.
}
The use Session;
method should also work.
If this still doesn't work you can use the session()
helper function which returns a session instance:
public function createSession($username)
{
session()->put('username', $username);
var_dump( session()->get('username') ); // outputs the value of $username
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community