Search code examples
cookiesarangodbfoxx

What is "Session/Cookie Transport"?


I'm building an app with ArangoDB.
In the manual, it says that there is something called Cookie transport and Session transports. https://docs.arangodb.com/3.11/develop/foxx-microservices/reference/sessions-middleware/session-transports/cookie-transport/

It seems that these are equivalent to cookies and sessions, like ones that you get with express-session modules. However, I can't understand:

  1. Why are these things called 'transport(s)' ?
  2. Do Cookie transport do the same as cookies?
    I'm using elixir/phoenix and other webservers behind nginx, and these servers must be able to have access to cookies.

Solution

  • A Transport is a type of object. You can create such an object like this:

    // use cookie based session
    const cookieTransport = require('@arangodb/foxx/sessions/transports/cookie');
    const myTransport = cookieTransport( ... );
    
    // -OR-
    
    // use header based session
    const headerTransport = require('@arangodb/foxx/sessions/transports/header');
    const myTransport = headerTransport( ... );
    

    You can use the Transport object myTransport like this for example:

    sessionsMiddleware({ ..., transport: myTransport });
    

    See https://docs.arangodb.com/3.11/develop/foxx-microservices/reference/sessions-middleware/ for details.

    You can also pass multiple Transport objects as array to the sessions middleware. If you don't want to change any of the default values, you can pass transport: ['header', 'cookie'] to support both cookie as well as header-based session transports.

    The transport defines how session IDs shall be handled on the client-side, whether a cookie or an HTTP header or both should be used to transmit the session ID to the server.