Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoSession ¶ added in v1.0.0
type MongoSession struct { ID primitive.ObjectID `bson:"_id,omitempty"` Data primitive.M `bson:"data,omitempty"` Modified primitive.DateTime `bson:"modified_at,omitempty"` Expires primitive.DateTime `bson:"expires_at,omitempty"` TTL primitive.DateTime `bson:"ttl,omitemtpy"` }
MongoSession is how sessions are stored in MongoDB.
type Options ¶ added in v1.0.0
type Options struct { Context context.Context Collection *mongo.Collection }
Options required for storing data in MongoDB.
type Store ¶ added in v1.0.0
type Store struct { sessions.CookieStore MongoStore // contains filtered or unexported fields }
Store stores sessions in Secure Cookies and MongoDB.
func NewStore ¶ added in v1.0.0
NewStore uses cookies and mongo to store sessions.
Keys are defined in pairs to allow key rotation, but the common case is to set a single authentication key and optionally an encryption key.
The first key in a pair is used for authentication and the second for encryption. The encryption key can be set to nil or omitted in the last pair, but the authentication key is required in all pairs.
It is recommended to use an authentication key with 32 or 64 bytes. The encryption key, if set, must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256 modes.
func (*Store) Get ¶ added in v1.0.0
Get returns a session for the given name after adding it to the registry.
It returns a new session if the sessions doesn't exist. Access IsNew on the session to check if it is an existing session or a new one.
It returns a new session and an error if the session exists but could not be decoded.