LoginController.php
if(Auth::attempt(['username' => $this->user, 'password' => $inp->password, 'Login' => $this->acct]))
{
# [2]: If TRUE, Create sessions, redirect
$authArr = SubUsers::join('sub_services as ss', 'sub_users.userid', '=', 'ss.userid')->where('sub_users.username', $this->user)->first()->toArray();
// Create The Sessions
Session::put('Username', $this->user); # constant | User that's currently logged in
Session::put('Account', $this->acct); # changing | Account Data being passed to view
Session::save();
Session::push('Auth', $authArr);
// Redirect
if(Session::has('lasturl')){
$lasturl = Session::get('lasturl');
return Redirect::to($lasturl);
}
else { return Redirect::to($this->startScreen); }
}
BaseAppController.php
public function __construct()
{
dd(Session::has('Username')); # [ This Returns Null ]
}
更新: 以下是存储在storage / framework / sessions文件夹中的会话。存储正确:
a:8:{s:6:"_token";s:40:"dEf3bJ4vz9fjiUuVnjD5EKNIKgJ38UzgZ0q4aE7K";s:9:"_previous";a:1:{s:3:"url";s:43:"http://localhost:8888/alpha/public/settings";}s:5:"flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}s:38:"login_82e5d2c56bdd0811318f0cf078b78bfc";i:78;s:8:"Username";s:4:"demo";s:7:"Account";s:4:"demo";s:4:"Auth";a:1:{i:0;a:20:{s:6:"userid";i:78;s:7:"groupid";N;s:5:"Login";s:4:"demo";s:8:"username";s:4:"demo";s:8:"password";s:60:"$2y$10$9Q1/zGeRrrDwl2rfjmkIWuWv3V/LpgFVYR/68PjANCsIkKmIVRVAu";s:4:"name";s:11:"John Babtis";s:5:"email";s:16:"jo@relatient.net";s:14:"remember_token";s:60:"2dqaWk56uJ1ldTdHhLcGg5U47JGxAD7EKdqwlr5qpPMGat9BKpMTf8tDtUlL";s:13:"userserviceid";i:81;s:9:"SuperUser";i:1;s:13:"MasterAccount";i:1;s:14:"canCreateUsers";i:1;s:12:"canEditUsers";i:1;s:2:"hm";i:1;s:6:"demand";i:1;s:9:"pophealth";i:1;s:12:"appointments";i:1;s:7:"reports";i:1;s:8:"settings";i:1;s:12:"canEditChild";i:1;}}s:9:"_sf2_meta";a:3:{s:1:"u";i:1437755751;s:1:"c";i:1437755740;s:1:"l";s:1:"0";}}
答案 0 :(得分:2)
尝试,username
全部小写。请记住,PHP区分大小写。
答案 1 :(得分:0)
为了更准确地回答 navasd 回答,用户名被Guard.php
文件中的Illuminate\Auth\Guard.php
覆盖。
它按名称存储会话,由于某种原因,它将Username存储为null并覆盖我的Session::put('Username')
会话变量。将其重命名为“用户名”虽然有效。