Getting ready...

As we have already created a session variable in our previous recipe using the Gorilla cookie store, we will just extend this recipe to save session information in Redis rather than maintaining it on the server.

There are multiple implementations of the Gorilla session store, which you can find at https://github.com/gorilla/sessions#store-implementations. As we are using Redis as our backend store, we will be using https://github.com/boj/redistore, which depends on the Redigo Redis library to store a session.

This recipe assumes you have Redis and Redis Browser installed and running locally on ports 6379 and 4567 respectively.

Get Go Web Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.