title: When is the serialize and deserialize passport method called? What does it exactly set?
body: <p>We have two types of Users, Admin and general Users.</p>
  
  <pre><code>passport.serializeUser(function(user, done) {
    console.log('Sear');
    done(null, user.id);
  });
  
  passport.deserializeUser(function(id, done) {
    console.log(id);
    console.log("Deser");
    User.findById(id, function(err, user) {
      if(err) done(err);
      if(user){
        done(null, user);  
      }else{
         vendorUser.findById(id, function(err, user){
          if(err) done(err);
          done(null,user);
         });
      }
    });
  });
  </code></pre>
  
  <p>Console.log gets outputted frequently (even on a single API request) with the text </p>
  
  <blockquote>
    <p>Deser</p>
  </blockquote>
  
  <p>What do both the functions exactly do? A detailed answer is appreciated. 
  TIA.</p>