<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;
use App\User;
***************************************************
Add a field name session_id with varchar(100).
To logout from other device add below lines in login controller.
protected function sendLoginResponse(Request $request)
{
$request->session()->regenerate();
$previous_session = Auth::User()->session_id;
if ($previous_session) {
Session::getHandler()->destroy($previous_session);
}
Auth::user()->session_id = Session::getId();
Auth::user()->save();
$this->clearLoginAttempts($request);
return $this->authenticated($request, $this->guard()->user())
?: redirect()->intended($this->redirectPath());
}
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;
use App\User;
***************************************************
Add a field name session_id with varchar(100).
To logout from other device add below lines in login controller.
protected function sendLoginResponse(Request $request)
{
$request->session()->regenerate();
$previous_session = Auth::User()->session_id;
if ($previous_session) {
Session::getHandler()->destroy($previous_session);
}
Auth::user()->session_id = Session::getId();
Auth::user()->save();
$this->clearLoginAttempts($request);
return $this->authenticated($request, $this->guard()->user())
?: redirect()->intended($this->redirectPath());
}
No comments:
Post a Comment