Sessions

The ctrl.activateSessions method and the related util-sessions-local Foxx service have been replaced with the Foxx sessions middleware. It is no longer possible to use the built-in session storage but you can simply pass in any document collection directly.

Old:

  1. const localSessions = applicationContext.dependencies.localSessions;
  2. const sessionStorage = localSessions.sessionStorage;
  3. ctrl.activateSessions({
  4. sessionStorage: sessionStorage,
  5. cookie: {secret: 'keyboardcat'}
  6. });
  7. ctrl.destroySession('/logout', function (req, res) {
  8. res.json({message: 'Goodbye!'});
  9. });

New:

  1. const sessionMiddleware = require('@arangodb/foxx/sessions');
  2. const cookieTransport = require('@arangodb/foxx/sessions/transports/cookie');
  3. router.use(sessionMiddleware({
  4. storage: module.context.collection('sessions'),
  5. transport: cookieTransport('keyboardcat')
  6. }));
  7. router.post('/logout', function (req, res) {
  8. req.sessionStorage.clear(req.session);
  9. res.json({message: 'Goodbye!'});
  10. });