Explain length and clear session storage methods in connection session

The express session documentation says that .length(callback)and methods .clear(callback)can be implemented in a custom session store implementation.

But should these methods do? Is it "indicate the number of registered sessions" and "delete all existing sessions"?

+4
source share
1 answer

Looking at it Mongo Session, it seems that you are right on both points. .lengthreturns the number of sessions, and .cleardeletes all data:

/**
 * Fetch number of sessions.
 *
 * @param {Function} callback
 * @api public
 */

 MongoStore.prototype.length = function(callback) {
    // code
  };

  /**
   * Clear all sessions.
   *
   * @param {Function} callback
   * @api public
   */

  MongoStore.prototype.clear = function(callback) {
    // code
  };
0
source

Source: https://habr.com/ru/post/1526724/


All Articles