本文整理汇总了PHP中Illuminate\Support\Facades\Session::getHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getHandler方法的具体用法?PHP Session::getHandler怎么用?PHP Session::getHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Session
的用法示例。
在下文中一共展示了Session::getHandler方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* Override login method
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
*/
public function login(Request $request)
{
$this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
$throttles = $this->isUsingThrottlesLoginsTrait();
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return $this->sendLockoutResponse($request);
}
$credentials = $this->getCredentials($request);
if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) {
//Find same user in db, kill the previous session and save current session id
$user = User::where('email', $request->get('email'))->first();
if (!is_null($user->session_id)) {
Session::getHandler()->destroy($user->session_id);
}
$user->session_id = Session::getId();
$user->save();
return $this->handleUserWasAuthenticated($request, $throttles);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return $this->sendFailedLoginResponse($request);
}
示例2: authenticated
protected function authenticated(Request $request, User $user)
{
$previousSessionID = $user->session;
if (!$previousSessionID) {
Session::getHandler()->destroy($previousSessionID);
}
$this->guard()->user()->session = Session::getId();
$this->guard()->user()->save();
return redirect()->intended($this->redirectPath());
}
示例3: testLoginExample
/**
* @group login
* @return $this
*/
public function testLoginExample()
{
$user_1 = App\User::where('email', 'guolingbo1991@gmail.com')->first();
if (is_null($user_1)) {
$this->visit('http://laratest.app/register')->type('lingbo', 'name')->type('guolingbo1991@gmail.com', 'email')->type('123123', 'password')->type('123123', 'password_confirmation')->press('Register')->seePageIs('http://laratest.app/home');
}
//Start another session(login another browser)
$response = $this->call('POST', '/login', ['email' => 'guolingbo1991@gmail.com', 'password' => '123123']);
$user_2 = App\User::where('email', 'guolingbo1991@gmail.com')->first();
var_dump($user_1->session_id);
var_dump($user_2->session_id);
$this->assertEquals("", Session::getHandler()->read($user_1->session_id));
$this->assertNotEquals("", Session::getHandler()->read($user_2->session_id));
}