Go Web Development Cookbook
上QQ阅读APP看书,第一时间看更新

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.