I login and then keep the username in a session, then I refresh this page, but the session not keep value.
This is my code:
class WelcomeCtrl extends Controller
{
public function gotoWelcome()
{
return view('welcome')->with('user',Session::get('user'));//nothing in session
}
public function dologin(){
$username = $_POST['username'];
$password = $_POST['password'];
$result = "";
if($username && $password){
$result = User::getUser($username, $password);
if($result){
Session::set('user',$result);
return response()->json([true, Session::get('user')]);//I get value expected, this is ok.
}
}
return response()->json([false, Session::get('user')]);
}
}