// Session returns a new logger with a nested session.
426326
func (l *LagerAdapter) Session(task string, data ...lager.Data) lager.Logger {
	tmpLogger := l.originalLogger.Session(task)

	if data != nil {
		tmpLogger = l.originalLogger.With(dataToFields(data)...)
	}

	return &LagerAdapter{
		originalLogger: tmpLogger,
	}
}
1147291
func (engine *Engine) Prepare() *Session {
	session := engine.NewSession()
	session.isAutoClose = true
	return session.Prepare()
}
633692
func (app *App) Session(accessToken string) *Session {
	return &Session{
		accessToken:          accessToken,
		app:                  app,
		enableAppsecretProof: app.EnableAppsecretProof,
	}
}
936924
func StartSession(ctx context.Context) context.Context {
	sessionTrackerOnce.Do(startSessionTracking)
	return sessionTracker.StartSession(ctx)
}
1241979
func (eg *EngineGroup) NewSession() *Session {
	sess := eg.Engine.NewSession()
	sess.sessionType = groupSession
	return sess
}
680444
func (s Session) AddSessionInfo(info string) Session {
	return s.appendString(TypeSessionInformation, info)
}
535811
func (c *Connection) log(v ...interface{}) {
	logLock.Lock()
	defer logLock.Unlock()
	if c.logger == nil {
		return
	}
	_, fn, ld, ok := runtime.Caller(1)

	if ok {
		c.logger.Printf("%s %s %d %v\n", c.session, fn, ld, v)
	} else {
		c.logger.Printf("%s %v\n", c.session, v)
	}
	return
}
351234
func (session *Session) Init() {
	session.statement.Init()
	session.statement.Engine = session.engine
	session.isAutoCommit = true
	session.isCommitedOrRollbacked = false
	session.isAutoClose = false
	session.autoResetStatement = true
	session.prepareStmt = false

	// !nashtsai! is lazy init better?
	session.afterInsertBeans = make(map[interface{}]*[]func(interface{}), 0)
	session.afterUpdateBeans = make(map[interface{}]*[]func(interface{}), 0)
	session.afterDeleteBeans = make(map[interface{}]*[]func(interface{}), 0)
	session.beforeClosures = make([]func(interface{}), 0)
	session.afterClosures = make([]func(interface{}), 0)
	session.stmtCache = make(map[uint32]*core.Stmt)

	session.afterProcessors = make([]executedProcessor, 0)

	session.lastSQL = ""
	session.lastSQLArgs = []interface{}{}

	session.ctx = session.engine.defaultContext
}
688463
func (ctx *Context) Session() *sessions.Session {
	// this help us if we call `Session()` multiple times in the same handler
	if ctx.session == nil {
		// start a new session if not created before.
		ctx.session = owner.sessionsManager.Start(ctx.Context)
	}

	return ctx.session
}
1013403
func (s *Sessions) Start(w http.ResponseWriter, r *http.Request) *Session {
	cookieValue := s.decodeCookieValue(GetCookie(r, s.config.Cookie))

	if cookieValue == "" { // cookie doesn't exists, let's generate a session and add set a cookie
		sid := s.config.SessionIDGenerator()

		sess := s.provider.Init(sid, s.config.Expires)
		sess.isNew = s.provider.db.Len(sid) == 0

		s.updateCookie(w, r, sid, s.config.Expires)

		return sess
	}

	sess := s.provider.Read(cookieValue, s.config.Expires)

	return sess
}
686703
func Init(url string, debugLog *log.Logger) *mgo.Session {

	if debugLog != nil {
		mgo.SetDebug(true)
		mgo.SetLogger(debugLog)
	}

	sess, err := mgo.DialWithTimeout(url, 15*time.Second)
	if err != nil {
		panic(err)
	}

	sess.SetMode(mgo.Monotonic, true)
	return sess
}
1233401
func (s *AssociateSoftwareTokenInput) SetSession(v string) *AssociateSoftwareTokenInput {
	s.Session = &v
	return s
}
17686
func (c *Client) Login(ctx context.Context, user *url.Userinfo) error {
	req := internal.URL(c, internal.SessionPath).Request(http.MethodPost)

	if user != nil {
		if password, ok := user.Password(); ok {
			req.SetBasicAuth(user.Username(), password)
		}
	}

	return c.Do(ctx, req, nil)
}
486950
func (sm *Manager) UserSession(ctx context.Context) (*types.UserSession, error) {
	var mgr mo.SessionManager

	pc := property.DefaultCollector(sm.client)
	err := pc.RetrieveOne(ctx, sm.Reference(), []string{"currentSession"}, &mgr)
	if err != nil {
		// It's OK if we can't retrieve properties because we're not authenticated
		if f, ok := err.(types.HasFault); ok {
			switch f.Fault().(type) {
			case *types.NotAuthenticated:
				return nil, nil
			}
		}

		return nil, err
	}

	return mgr.CurrentSession, nil
}
1255996
func Session(store sessions.Store, options *SessionOptions) HandlerFunc {
	var sessionOptions *sessions.Options

	if options != nil {
		sessionOptions = &sessions.Options{
			Path:     options.Path,
			Domain:   options.Domain,
			MaxAge:   options.MaxAge,
			Secure:   options.Secure,
			HttpOnly: options.HTTPOnly,
		}
	}

	manager := sessions.New(512, store, sessionOptions)

	return func(c *C) {
		c.sessions = manager.GetSessions(c.Request)
		defer manager.Close(c.sessions)

		c.Writer.Before(func(ResponseWriter) {
			c.sessions.Save(c.Writer)
		})

		c.Next()
	}
}
364914
func (s *MemcacheStore) load(session *sessions.Session) error {

	key := s.KeyPrefix + session.ID

	val, _, _, err := s.Client.Get(key)
	if s.Logging > 0 {
		if s.StoreMethod == StoreMethodJson {
			log.Printf("gorilla-sessions-memcache: get (method: %s, session name: %v, memcache key: %v, memcache value: %v, error: %v)", s.StoreMethod, session.Name(), key, val, err)
		} else {
			log.Printf("gorilla-sessions-memcache: get (method: %s, session name: %v, memcache key: %v, memcache value len: %v, error: %v)", s.StoreMethod, session.Name(), key, len(val), err)
		}
	}
	if err != nil {
		return err
	}

	switch s.StoreMethod {

	case StoreMethodSecureCookie:

		if err = securecookie.DecodeMulti(session.Name(), val,
			&session.Values, s.Codecs...); err != nil {
			if s.Logging > 0 {
				log.Printf("gorilla-sessions-memcache: get (method: securecookie, decoding error: %v)", err)
			}
			return err
		}
		return nil

	case StoreMethodGob:

		buf := bytes.NewBuffer([]byte(val))
		dec := gob.NewDecoder(buf)

		err = dec.Decode(&session.Values)
		if err != nil {
			if s.Logging > 0 {
				log.Printf("gorilla-sessions-memcache: get (method: gob, decoding error: %v)", err)
			}
		}
		return err

	case StoreMethodJson:

		vals := make(map[string]interface{})

		err := json.Unmarshal([]byte(val), &vals)
		if err != nil {
			if s.Logging > 0 {
				log.Printf("gorilla-sessions-memcache: get (method: json, decoding error: %v)", err)
			}
			return err
		}

		for k, v := range vals {
			session.Values[k] = v
		}

		return nil

	default:
		panic("Unknown StoreMethod: " + string(s.StoreMethod))

	}

	panic("Unreachable")
	return nil
}
507863
func (record *SessionRecord) Serialize() ([]byte, error) {
	rs := &protobuf.RecordStructure{}
	rs.CurrentSession = record.sessionState.SS
	for _, s := range record.PreviousStates {
		rs.PreviousSessions = append(rs.PreviousSessions, s.SS)
	}
	b, err := proto.Marshal(rs)
	if err != nil {
		return nil, err
	}
	return b, nil
}