Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoStore ¶
type MongoStore struct { Codecs []securecookie.Codec Options *sessions.Options // contains filtered or unexported fields }
MongoStore stores sessions as documents in a MongoDB collection.
func New ¶
func New(db *mongo.Database, collName string, opts *sessions.Options, keyPairs ...[]byte) *MongoStore
New returns a new MongoStore instance.
func (*MongoStore) Get ¶
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.
func (*MongoStore) MaxAge ¶
func (s *MongoStore) MaxAge(age int)
MaxAge sets the maximum age for the store and the underlying cookie implementation. Individual sessions can be deleted by setting Options.MaxAge = -1 for that session.
func (*MongoStore) New ¶
New returns a session for the given name without adding it to the registry.
The difference between New() and Get() is that calling New() twice will decode the session data twice, while Get() registers and reuses the same decoded session after the first call.
func (*MongoStore) Save ¶
func (s *MongoStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Save adds a single session to the response.
If the Options.MaxAge of the session is < 0 then the session document will be deleted from the MongoDB collection.