O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The session store

Unlike the product records, which are stored in the Redis database, the items a user chooses to place in their shopping cart is transitory, and it's customized for individual use. This being the case, it makes much more sense to store the state of the shopping cart in a session, rather than in the database.

We will use the Gorilla sessions package to create sessions and store data to the sessions. We will utilize the session.NewFileSystemStore type to save the session data to the server's file system.

First, we will add a new field (shown in bold) to the common.Env struct (defined in the common/common.go source file), which will hold the FileSystemStore instance so that it is accessible throughout the server-side web application: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required