The sessions we've created so far are stored in the program memory. This means if the program crashes or restarts, all the logged sessions will be lost. It needs the client to log in once again to get a new session cookie. This is not helpful for auditing cookies. In order to save sessions somewhere, we can use Redis.
We have discussed running Redis in a Docker container in Chapter 9, Asynchronous API Design. To recap, the Redis server stores key-value pairs. It provides basic data types such as strings, lists, hashes, sets, and so on. For more details, visit https://redis.io/topics/data-types.
Now, it is time to put our Redis knowledge into action. We are going to modify our project from simpleAuth to simpleAuthWithRedis. The new project should now use Redis as a session store. Copy the code from the previous example to the new one.
...