I solved using the following code below:
var app = require('express')();
var http = require('http').Server(app);
var session = require('express-session');
var express = require('express');
app.set('trust proxy', 1) // trust first proxy
app.use(session({
secret: 's3ssIon',
resave: false,
saveUninitialized: true
}));
app.get('/', function (req, res) {
req.session.formula = [];
req.session.views = (req.session.views || 0) + 1
req.session.formula.push(req.session.views);
res.end(req.session.views + ' views')
});
app.get('/resultado', function (req, res) {
req.session.views = (req.session.views || 0) + 1
req.session.formula.push(req.session.views);
res.end(req.session.views + ' views')
});
app.get('/fim', function (req, res) {
req.session.destroy();
res.end('Session encerrada')
});
http.listen(3000, function () {
console.log("Connected");
});
I configured the Session, created 3 routes (root, result and end), I used [] to create the array and the push method to include the values.