logout on session exprier in laravel code example
Example 1: auto logout when session expires laravel
class AddLastSeenToUsersTable extends Migration
{
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->timestamp('last_seen_at')->nullable();
});
}
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('last_seen_at');
});
}
}
Example 2: auto logout when session expires laravel
class LoginController extends Controller
{
// ...
protected function authenticated(Request $request, $user)
{
$user->last_seen_at = Carbon::now()->format('Y-m-d H:i:s');
$user->save();
}
}