Install using composer:
composer require jenssegers/mongodb-session
config/app.php
'providers' => [
Jenssegers\Mongodb\MongodbServiceProvider::class,
Jenssegers\Mongodb\Session\SessionServiceProvider::class,
Jenssegers\Mongodb\Auth\PasswordResetServiceProvider::class,
Change the session driver in app/config/session.php to mongodb
'driver' => 'mongodb',
Optional: change the connection to a connection using the mongodb driver from app/config/database.php:
'connection' => 'mongodb',
User model
namespace App;
use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Eloquent implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
use Notifiable;