Get value from request/session and save value to session
775442
def get_and_save_value(self, name, default=None):
        """"""
        if getattr(self, name, None):
            return getattr(self, name)

        value = self.get_session_value(name, default)
        value = self.request.POST.get(name, value)
        self.save_value(name, value)
        return value
960211
def save(self):
        
        resp = self.r_session.put(
            self.document_url,
            data=self.json(),
            headers={'Content-Type': 'application/json'}
        )
        resp.raise_for_status()
575124
function (req) {
	var cookie = SR.REST.getCookie(req.headers.cookie);
	var session = SR.EventManager.getSession(cookie);
	return session;
}
491784
function Session (ctx, obj) {
  Object.defineProperty(this, '_ctx', {
    value: ctx
  })

  if (obj) {
    for (var key in obj) {
      this[key] = obj[key]
    }
  }
}
48312
def _get(self, url, **kw):
        '''
        
        '''
        headers = kw.pop('headers', {})
        headers.setdefault('Content-Type', 'application/json')
        headers.setdefault('Accept', 'application/json')
        headers.setdefault('Authorization', self.AUTHORIZATION_HEADER)
        kw['headers'] = headers
        resp = self.session.get(url, **kw)
        self._raise_for_status(resp)
        return resp
1245328
def save_session_to_file(self, sessionfile):
        """"""
        pickle.dump(requests.utils.dict_from_cookiejar(self._session.cookies), sessionfile)
456507
async def save_session(self, sid, session):
        
        socket = self._get_socket(sid)
        socket.session = session
197864
def save(self):
        
        result = yield gen.Task(RedisSession._redis_client.set,
                                self._key, self.dumps())
        LOGGER.debug('Saved session %s (%r)', self.id, result)
        raise gen.Return(result)
1000124
def post_session():
    

    url_string = "{}/users/me/session".format(WinkApiInterface.BASE_URL)

    nonce = ''.join([str(random.randint(0, 9)) for i in range(9)])
    _json = {"nonce": str(nonce)}

    try:
        arequest = requests.post(url_string,
                                 data=json.dumps(_json),
                                 headers=API_HEADERS)
        response_json = arequest.json()
        return response_json
    except requests.exceptions.RequestException:
        return None
970508
function makeSession(session) {
  return {
    authenticated: !!session.token,
    token: session.token,
    scope: session.scope,
    error: session.error,
    errorDescription: session.errorDescription
  };
}
1008411
def session(self, value):
        """"""

        # unset session token
        if value is None:
            self._session = None
            return

        if not isinstance(value, dict):
            raise ValueError("session info is required")

        session_parsed = {}

        for key in ["session_token", "time", "secret_key"]:
            if key not in value:
                raise ValueError("Missing parameter: {}".format(key))
            session_parsed[key] = value[key]

        for key in ["ekey", "pkey"]:
            # nice to have, but not mandatory
            if key in value:
                session_parsed[key] = value[key]

        self._session = session_parsed
1058216
def save():
    '''
    '''
    if request.method == 'POST':
        exp_id = session.get('exp_id')
        app.logger.debug('Saving data for %s' %exp_id)

        fields = get_post_fields(request)
        result_file = app.save_data(session=session, content=fields, exp_id=exp_id)

        experiments = app.finish_experiment(session, exp_id)
        app.logger.info('Finished %s, %s remaining.' % (exp_id, len(experiments)))

        # Note, this doesn't seem to be enough to trigger ajax success
        return json.dumps({'success':True}), 200, {'ContentType':'application/json'} 
    return json.dumps({'success':False}), 403, {'ContentType':'application/json'}
1073383
private void saveSession(Session session) throws UnknownSessionException{
		if(session == null || session.getId() == null){
			logger.error("session or session id is null");
			return;
		}
		
		byte[] key = getByteKey(session.getId());
		byte[] value = SerializeUtils.serialize(session);
		
		
		session.setTimeout(this.getExpire()*1000);		
		
		if(redisTemplate!=null) {
			redisTemplate.opsForValue().set(getKey(session.getId()), value, this.getExpire(), TimeUnit.SECONDS);
		}else {
			this.redisManager.set(key, value, this.getExpire());
		}
		
	}
1150616
def make_request(self, session, url, **kwargs):
        
        log.debug('Making request: GET %s %s' % (url, kwargs))
        return session.get(url, **kwargs)
166968
def post(request):
    
    data = request.POST or json.loads(request.body)['body']
    key = data.get('key', None)
    val = data.get('val', None)
    res = Result()
    if key is not None and val is not None:
        obj, created = UserPref.objects.get_or_create(user=request.user)
        if created:
            obj.data = json.dumps(DefaultPrefs.copy())
            obj.save()
        try:
            val = json.loads(val)
        except (TypeError, ValueError):
            pass
        obj.setKey(key, val)
        obj.save()
        res.append(obj.json())

    return JsonResponse(res.asDict())
1127769
async function getSession (url) {
  const token = await loadToken(url)
  if (!token) return null
  const header = jwt.decode(token)
  if (!header) return null
  const now = Math.floor(Date.now() / 1000)
  if (header.exp <= now) return null
  return header
}
19387
def get_session(self, session_id: int) -> Optional[Session]:
        
        try:
            data = self._client.get(f"/sessions/{session_id}")
        except requests.HTTPError as e:
            if e.response.status_code == 404:
                return None
            else:
                raise
        return Session.from_json(data)