Level Up Your Web Apps With Go by Mal Curtis

Level Up Your Web Apps With Go by Mal Curtis

Author:Mal Curtis [Curtis, Mal]
Language: eng
Format: epub, mobi, pdf
ISBN: 9780992461294
Publisher: SitePoint Pty. Ltd.
Published: 2015-08-16T04:00:00+00:00


What makes up a session?

A session can be used to store any information we choose. Since we’ll be defining a session type, we can add any fields we want. For Gophr, the only information we’ll require at this point is the user that we want to keep logged in. So, along with the identifier and expiry values, our session type looks like this:

1_new_session/session.go (excerpt)

type Session struct { ID string UserID string Expiry time.Time }

We need to know how long to keep a session active for, and the name of the cookie that we store it in, so let’s define a couple of constants with those values:

1_new_session/session.go (excerpt)

const ( // Keep users logged in for 3 days sessionLength = 24 * 3 * time.Hour sessionCookieName = "GophrSession" sessionIDLength = 20 )



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.