title: Session is not beeing created with Passport.js
body: <p>I created some code to work with Google OAuth2 with Passport.js, but my code doesn't seem to create a session after the user had successfully authenticated .</p>
  <p>Everything else works, just not the sessions.</p>
  <p>My auth code:</p>
  <pre class="lang-js prettyprint-override"><code>const passport = require(&quot;passport&quot;);
  const GoogleStrategy = require(&quot;passport-google-oauth20&quot;).Strategy;
  const User = require(&quot;../database/models/User&quot;);
  
  passport.serializeUser((user, done) =&gt; {
    done(null, user.userID);
  });
  
  passport.deserializeUser(async (userID, done) =&gt; {
    try {
      const user = await User.findOne({ userID: userID });
      return done(null, user);
    } catch (err) {
      console.log(err);
      done(err, null);
    }
  });
  
  passport.use(
    new GoogleStrategy(
      {
        clientID:
          &quot;my client id&quot;,
        clientSecret: &quot;my client secret&quot;,
        callbackURL: &quot;/api/v1/auth/google/redirect&quot;,
        scope: [&quot;profile&quot;],
      },
      async (accessToken, refreshToken, profile, done) =&gt; {
        const { _json } = profile;
        try {
          const findUser = await User.findOneAndUpdate(
            { userID: _json.sub },
            {
              email: _json.email,
              avatar: _json.picture,
              username: _json.name,
            },
            { new: true }
          );
          if (findUser) {
            console.log(&quot;user has been found!&quot;);
            return done(null, findUser);
          } else {
            const newUser = await User.create({
              userID: _json.sub,
              avatar: _json.picture,
              username: _json.name,
              email: _json.email,
            });
            return done(null, newUser);
          }
        } catch (err) {
          console.log(err);
          done(err, null);
        }
      }
    )
  );
  </code></pre>
  <p>and my passport and session setup:</p>
  <pre class="lang-js prettyprint-override"><code>app.use(
    session({
      secret: &quot;secret&quot;,
      cookie: { maxAge: 3600 * 60 * 24, domain: &quot;lvh.me:3001&quot; },
      resave: false,
      saveUninitialized: false,
      store: new Store({ mongooseConnection: mongoose.connection }),
    })
  );
  
  app.use(passport.initialize());
  app.use(passport.session());
  
  </code></pre>