func (s *MongoStore) New(r *http.Request, name string) (*sessions.Session, error) { session := sessions.NewSession(s, name) session.Options = &(*s.Options) session.IsNew = true var err error if c, errCookie := r.Cookie(name); errCookie == nil { err = securecookie.DecodeMulti(name, c.Value, &session.ID, s.Codecs...) if err == nil { err = s.load(session) if err == nil { session.IsNew = false } } } // Remove older sessions s.DBCollection.RemoveAll(bson.M{ "age": bson.M{ "$lt": bson.Now().Add(time.Duration(-s.Options.MaxAge) * time.Second), }, }) return session, err }
// New returns a session for the given name without adding it to the registry. // // See CookieStore.New(). func (s *DatastoreStore) New(r *http.Request, name string) (*sessions.Session, error) { session := sessions.NewSession(s, name) session.IsNew = true var err error if c, errCookie := r.Cookie(name); errCookie == nil { err = securecookie.DecodeMulti(name, c.Value, &session.ID, s.Codecs...) if err == nil { err = s.load(r, session) if err == nil { session.IsNew = false } } } return session, err }
// New returns a session for the given name without adding it to the registry. // // See CookieStore.New(). func (s *redisStore) New(r *http.Request, name string) (*sessions.Session, error) { var c *http.Cookie var err error c, err = r.Cookie(name) if err != nil && err != http.ErrNoCookie { return nil, err } var session *sessions.Session session = sessions.NewSession(s, name) session.IsNew = true if c != nil { securecookie.DecodeMulti(name, c.Value, &session.ID, s.Codecs...) s.load(session) if len(session.Values) > 0 { session.IsNew = false } } return session, nil }