// GetSession returns a session by ID
769633
func (c *Client) GetSession(namespace string, id session.ID) (*session.Session, error) {
	if namespace == "" {
		return nil, trace.BadParameter(MissingNamespaceError)
	}
	// saving extra round-trip
	if err := id.Check(); err != nil {
		return nil, trace.Wrap(err)
	}
	out, err := c.Get(c.Endpoint("namespaces", namespace, "sessions", string(id)), url.Values{})
	if err != nil {
		return nil, trace.Wrap(err)
	}
	var sess *session.Session
	if err := json.Unmarshal(out.Bytes(), &sess); err != nil {
		return nil, trace.Wrap(err)
	}
	return sess, nil
}
277109
func (s *Session) Get(key string) interface{} {
	if s.data == nil {
		return nil
	}
	return s.data[key]
}
827930
func (sg *sessionPool) get() (sessionctx.Context, error) {
	if sg.resPool == nil {
		return mock.NewContext(), nil
	}

	sg.mu.Lock()
	if sg.mu.closed {
		sg.mu.Unlock()
		return nil, errors.Errorf("sessionPool is closed.")
	}
	sg.mu.Unlock()

	// no need to protect sg.resPool
	resource, err := sg.resPool.Get()
	if err != nil {
		return nil, errors.Trace(err)
	}

	ctx := resource.(sessionctx.Context)
	ctx.GetSessionVars().SetStatusFlag(mysql.ServerStatusAutocommit, true)
	ctx.GetSessionVars().InRestrictedSQL = true
	return ctx, nil
}
305185
func (c *lruSessionCache) Get(sessionKey string) (*ClientSessionState, bool) {
	c.Lock()
	defer c.Unlock()

	if elem, ok := c.m[sessionKey]; ok {
		c.q.MoveToFront(elem)
		return elem.Value.(*lruSessionCacheEntry).state, true
	}
	return nil, false
}
1135191
func (s *Session) GetString(key string, def string) string {
	v, ok := s.Values[key]
	if !ok {
		return def
	}

	return v.(string)
}
1124925
func (s *Session) Get(key string) interface{} {
	return s.provider.db.Get(s.sid, key)
}
454511
func (s *session) Get(table Table, opts ...GetOption) (bool, error) {
	action, ok, err := s.get(table, s.applyGetOption(opts), table.TableMeta().Fields()...)
	if err != nil {
		return ok, s.catch("Get: "+action, err)
	}
	return ok, nil
}
13665
func Session(r *http.Request, name string) *sessions.Session {
	session, _ := Store.Get(r, name)
	return session
}
1232388
func (s *Session) GetString(key string) string {
	r, _ := s.Get(key).(string)
	return r
}
365777
func (s *server) GetSession(namespace string, id ID) (*Session, error) {
	item, err := s.bk.Get(context.TODO(), activeKey(namespace, string(id)))
	if err != nil {
		if trace.IsNotFound(err) {
			return nil, trace.NotFound("session(%v, %v) is not found", namespace, id)
		}
		return nil, trace.Wrap(err)
	}
	var sess Session
	if err := json.Unmarshal(item.Value, &sess); err != nil {
		return nil, trace.Wrap(err)
	}
	return &sess, nil
}
541757
func (c *Ctx) GetSessionInfo(sh SessionHandle) (SessionInfo, error) {
	var csi C.CK_SESSION_INFO
	e := C.GetSessionInfo(c.ctx, C.CK_SESSION_HANDLE(sh), &csi)
	s := SessionInfo{SlotID: uint(csi.slotID),
		State:       uint(csi.state),
		Flags:       uint(csi.flags),
		DeviceError: uint(csi.ulDeviceError),
	}
	return s, toError(e)
}
897476
func (handle *ContextHandle) GetSession() (session mPkcs11.SessionHandle) {
	handle.lock.RLock()
	select {
	case session = <-handle.sessions:
		logger.Debugf("Reusing existing pkcs11 session %+v on slot %d\n", session, handle.slot)

	default:

		// cache is empty (or completely in use), create a new session
		s, err := handle.OpenSession()
		if err != nil {
			handle.lock.RUnlock()
			panic(fmt.Errorf("OpenSession failed [%s]", err))
		}
		logger.Debugf("Created new pkcs11 session %+v on slot %d\n", s, handle.slot)
		session = s
		cachebridge.ClearSession(fmt.Sprintf("%d", session))
	}
	handle.lock.RUnlock()
	return handle.validateSession(session)
}
269291
func getMongoSession() *mgo.Session {
	session, err := mgo.Dial(*mongoIP)
	if err != nil {
		log.Fatal("Error dailing mongodb")
	}
	session.SetMode(mgo.Strong, true)

	return session
}
157121
func (s *SessionService) FindSession(ctx context.Context, key string) (*platform.Session, error) {
	return s.FindSessionFn(ctx, key)
}
611809
func (sw *SplunkHandler) getSessionKey() (string, error) {
	if sw.sessionKey == "" || sw.sessionKeyTime.Before(time.Now().Add(-sessionKeyDuration)) {
		var err error
		sw.sessionKey, err = sw.login()
		if err != nil {
			return "", err
		}

		sw.sessionKeyTime = time.Now()
	}

	return sw.sessionKey, nil
}
715697
func (s *SessionClient) Get(ctx context.Context) (*apitypes.SessionStatus, error) {
	resp := &apitypes.SessionStatus{}
	err := s.client.DaemonRoundTrip(ctx, "GET", "/session", nil, nil, resp, nil)
	return resp, err
}
386646
func (s *server) GetSessions(namespace string) ([]Session, error) {
	prefix := activePrefix(namespace)

	result, err := s.bk.GetRange(context.TODO(), prefix, backend.RangeEnd(prefix), MaxSessionSliceLength)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	out := make(Sessions, 0, len(result.Items))

	for i := range result.Items {
		var session Session
		if err := json.Unmarshal(result.Items[i].Value, &session); err != nil {
			return nil, trace.Wrap(err)
		}
		out = append(out, session)
	}
	sort.Stable(out)
	return out, nil
}