// Initialize session manager store := sessions.NewCookieStore([]byte("secret-key")) // Retrieve session data session := sessions.Get(req) name := session.Get("username")
// Initialize session manager store := sessions.NewCookieStore([]byte("secret-key")) // Set session value session := sessions.Get(req) session.Set("username", "johndoe") session.Save()In this example, we first initialize a session store using `NewCookieStore` and a secret key. Then, we retrieve the session for the current request using `sessions.Get`, and set the value of the `username` key to `"johndoe"` using `session.Set`. Finally, we call `session.Save` to persist the session data. The `github.com/martini-contrib/sessions` package is part of the Martini-contrib project, which provides various utilities and middleware for the Martini web framework.