// StoreInSession stores a specified key/value pair in the session.
342026
func StoreInSession(key string, value string, req *http.Request, res http.ResponseWriter) error {
	session, _ := Store.New(req, SessionName)

	if err := updateSessionValue(session, key, value); err != nil {
		return err
	}

	return session.Save(req, res)
}
875095
func newSession(maxAge int) *Session {
	uid, err := uuid.NewV4()
	if err != nil {
		panic(ErrNoSessionID)
	}
	return &Session{
		true, // is new
		internalSession{
			make(map[string]interface{}),
			uid.String(),
			time.Now(),
			time.Duration(maxAge) * time.Second,
		},
	}
}
660027
func (s *CreatePresignedNotebookInstanceUrlInput) SetSessionExpirationDurationInSeconds(v int64) *CreatePresignedNotebookInstanceUrlInput {
	s.SessionExpirationDurationInSeconds = &v
	return s
}
912420
func NewEventStoreWithSession(session *mgo.Session, dbPrefix string) (*EventStore, error) {
	if session == nil {
		return nil, ErrNoDBSession
	}

	s := &EventStore{
		session:  session,
		dbPrefix: dbPrefix,
	}

	return s, nil
}
813479
func (s *VerifySoftwareTokenOutput) SetSession(v string) *VerifySoftwareTokenOutput {
	s.Session = &v
	return s
}
385402
func (s *AdminRespondToAuthChallengeInput) SetSession(v string) *AdminRespondToAuthChallengeInput {
	s.Session = &v
	return s
}
456355
func (mgr *MemorySessionManager) NewSession() (Session, error) {
	sid, err := mgr.sessionID()
	if err != nil {
		return nil, err
	}
	s := MemorySession{sid: sid, data: make(map[string]interface{}), createdAt: time.Now()}
	mgr.lock.Lock()
	mgr.sessions[sid] = &s
	mgr.lock.Unlock()
	return &s, nil
}
471028
func (s *AdminInitiateAuthOutput) SetSession(v string) *AdminInitiateAuthOutput {
	s.Session = &v
	return s
}
1265182
func newSession(stor storage.Storage, o *opt.Options) (s *session, err error) {
	if stor == nil {
		return nil, os.ErrInvalid
	}
	storLock, err := stor.Lock()
	if err != nil {
		return
	}
	s = &session{
		stor:     stor,
		storLock: storLock,
		fileRef:  make(map[int64]int),
	}
	s.setOptions(o)
	s.tops = newTableOps(s)
	s.setVersion(newVersion(s))
	s.log("log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed")
	return
}
680444
func (s Session) AddSessionInfo(info string) Session {
	return s.appendString(TypeSessionInformation, info)
}
687629
func StoreKeysIncompat(k I2PKeys, w io.Writer) (err error) {
	_, err = io.WriteString(w, k.addr.Base64()+"\n"+k.both)
	return
}
1117580
func addSession(key string, app *App) {
	mutex.Lock()
	defer mutex.Unlock()

	sessions[key] = app
}
1087770
func (s *FilesystemStore) save(session *Session) error {
	encoded, err := securecookie.EncodeMulti(session.Name(), session.Values,
		s.Codecs...)
	if err != nil {
		return err
	}
	filename := filepath.Join(s.path, "session_"+session.ID)
	fileMutex.Lock()
	defer fileMutex.Unlock()
	return ioutil.WriteFile(filename, []byte(encoded), 0600)
}
262181
func (s *VerifySoftwareTokenInput) SetSession(v string) *VerifySoftwareTokenInput {
	s.Session = &v
	return s
}
750488
func (mgr *MemorySessionManager) Session(sid string) (Session, error) {
	mgr.lock.RLock()
	if s, ok := mgr.sessions[sid]; ok {
		s.createdAt = time.Now()
		mgr.lock.RUnlock()
		return s, nil
	}
	mgr.lock.RUnlock()
	return nil, fmt.Errorf("Can not retrieve session with id %s", sid)
}
1351544
func (s *Restore) Session(sess *structs.Session) error {
	// Insert the session.
	if err := s.tx.Insert("sessions", sess); err != nil {
		return fmt.Errorf("failed inserting session: %s", err)
	}

	// Insert the check mappings.
	for _, checkID := range sess.Checks {
		mapping := &sessionCheck{
			Node:    sess.Node,
			CheckID: checkID,
			Session: sess.ID,
		}
		if err := s.tx.Insert("session_checks", mapping); err != nil {
			return fmt.Errorf("failed inserting session check mapping: %s", err)
		}
	}

	// Update the index.
	if err := indexUpdateMaxTxn(s.tx, sess.ModifyIndex, "sessions"); err != nil {
		return fmt.Errorf("failed updating index: %s", err)
	}

	return nil
}
1167352
func (s *DumbMemoryStore) save(session *sessions.Session) error {
	encoded, err := securecookie.EncodeMulti(session.Name(), session.Values,
		s.Codecs...)
	if err != nil {
		return err
	}

	s.Data[session.ID] = encoded

	return nil
}