func (d *dalStore) Save(r *http.Request, w http.ResponseWriter, session *gSessions.Session) error { if session.Options.MaxAge < 0 { if err := d.delete(session); err != nil { return err } d.Token.SetToken(w, session.Name(), "", session.Options) return nil } if session.ID == "" { session.ID = dal.NewObjectID().Hex() } if err := d.save(session); err != nil { return err } //save just the id to the cookie, the rest will be saved in the dal store encoded, err := securecookie.EncodeMulti(session.Name(), session.ID, d.Codecs...) if err != nil { return err } d.Token.SetToken(w, session.Name(), encoded, session.Options) return err }
//Save persists the user to the database through the dal func (u *User) Save(db *dal.Database) (err error) { col := (*db).C(userCollection) if !u.ID.Valid() { u.ID = dal.NewObjectID() } _, err = col.UpsertID(u.ID, u) return err }