当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::getHandler方法代码示例

本文整理汇总了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);
 }
开发者ID:lingboguo,项目名称:Laravel5Login,代码行数:34,代码来源:AuthController.php

示例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());
 }
开发者ID:sthWrong,项目名称:season5.co,代码行数:10,代码来源:LoginController.php

示例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));
 }
开发者ID:lingboguo,项目名称:Laravel5Login,代码行数:18,代码来源:ExampleTest.php


注:本文中的Illuminate\Support\Facades\Session::getHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。