--> NOTE that this object is only assigned once, per session and does not change for this constructor name during open session. local storage for recalling conversations upon restart
490652
function() {
    var test = "chat-bubble-storage-test"
    try {
      localStorage.setItem(test, test)
      localStorage.removeItem(test)
      return true
    } catch (error) {
      console.error(
        "Your server does not allow storing data locally. Most likely it's because you've opened this page from your hard-drive. For testing you can disable your browser's security or start a localhost environment."
      )
      return false
    }
  }
891643
public void save(String storageName) {
        //store the objects on storage
        storageEngine.saveObject("modelParameters", modelParameters);
        storageEngine.saveObject("trainingParameters", trainingParameters);

        //rename the storage
        storageEngine.rename(storageName);

        //reload the model parameters, necessary for the maps to point to the new location
        modelParameters = (MP) storageEngine.loadObject("modelParameters", ModelParameters.class);
    }
660443
def transaction(self, session=None):
        
        local_session = None
        if session is None:
            local_session = session = self.create_scoped_session()
        try:
            yield session
        finally:
            # Since ``local_session`` was created locally, close it here itself
            if local_session is not None:
                # but wait!
                # http://groups.google.com/group/sqlalchemy/browse_thread/thread/7c1eb642435adde7
                # To workaround this issue with sqlalchemy, we can either:
                #  1) pass the session object explicitly
                #  2) do not close the session at all (bad idea - could lead to memory leaks)
                #
                # Till pypm implements atomic transations in client.installer,
                # we retain this hack (i.e., we choose (2) for now)
                pass
532021
@Override
  public IRoSessionData getAppSessionData(Class<? extends AppSession> clazz, String sessionId) {
    if (clazz.equals(ClientRoSession.class)) {
      ClientRoSessionDataLocalImpl data = new ClientRoSessionDataLocalImpl();
      data.setSessionId(sessionId);
      return data;
    }
    else if (clazz.equals(ServerRoSession.class)) {
      ServerRoSessionDataLocalImpl data = new ServerRoSessionDataLocalImpl();
      data.setSessionId(sessionId);
      return data;
    }
    throw new IllegalArgumentException(clazz.toString());
  }
59574
def initializeSession(sessionState, sessionVersion, parameters):
        
        if RatchetingSession.isAlice(parameters.getOurBaseKey().getPublicKey(), parameters.getTheirBaseKey()):
            aliceParameters = AliceAxolotlParameters.newBuilder()
            aliceParameters.setOurBaseKey(parameters.getOurBaseKey()) \
                .setOurIdentityKey(parameters.getOurIdentityKey()) \
                .setTheirRatchetKey(parameters.getTheirRatchetKey()) \
                .setTheirIdentityKey(parameters.getTheirIdentityKey()) \
                .setTheirSignedPreKey(parameters.getTheirBaseKey()) \
                .setTheirOneTimePreKey(None)
            RatchetingSession.initializeSessionAsAlice(sessionState, sessionVersion, aliceParameters.create())
        else:
            bobParameters = BobAxolotlParameters.newBuilder()
            bobParameters.setOurIdentityKey(parameters.getOurIdentityKey()) \
                .setOurRatchetKey(parameters.getOurRatchetKey()) \
                .setOurSignedPreKey(parameters.getOurBaseKey()) \
                .setOurOneTimePreKey(None) \
                .setTheirBaseKey(parameters.getTheirBaseKey()) \
                .setTheirIdentityKey(parameters.getTheirIdentityKey())
            RatchetingSession.initializeSessionAsBob(sessionState, sessionVersion, bobParameters.create())
950300
function SessionStorage_construct(config) {
        this.timeouts = {};
        this.config = core.extend(
            {
                cookieKey: 'session_id',
                time: 60 * 20 * 1000, // 20 min default session time
                storage: null,
                key_prefix: 'SESSION_ID_KEY_'
            },
            config
        );

        if (!this.config.storage) {
            this.config.storage = cache;
        } else if (Type.isString(this.config.storage)) {
            this.config.storage = di.load(this.config.storage);
        }

        if(!(this.config.storage instanceof StorageInterface)) {
            throw new error.HttpError(500, this.config, 'Session storage must be instance of interface/storage');
        }
    }
391355
function _initStorage$2(options) {
    var self = this;
    var dbInfo = {};
    if (options) {
        for (var i in options) {
            dbInfo[i] = options[i];
        }
    }

    dbInfo.keyPrefix = _getKeyPrefix(options, self._defaultConfig);

    if (!_isLocalStorageUsable()) {
        return Promise$1.reject();
    }

    self._dbInfo = dbInfo;
    dbInfo.serializer = localforageSerializer;

    return Promise$1.resolve();
}
214336
def get_local(self, key, default=None, scope=None):
        
        return self.conversation(scope).get_local(key, default)
1268784
function resume (instance, state) {
  if (instance.__hibernated) {
    instance.__hibernated = false
  } else {
    // initialize memory
    const mem = instance.exports[`${state.symbol}memory`]
    if (mem) {
      (new Uint32Array(mem.buffer)).set(state.memory, 0)
    }

    // initialize table
    if (instance.exports._table) {
      for (const index in state.table) {
        const funcIndex = state.table[index]
        instance.exports._table.set(index, instance.exports[`${state.symbol}func_${funcIndex}`])
      }
    }

    // initialize globals
    for (const index in state.globals) {
      const val = state.globals[index]
      if (val !== undefined) {
        if (Array.isArray(val)) {
          instance.exports[`${state.symbol}global_setter_i64_${index}`](val[1], val[0])
        } else {
          instance.exports[`${state.symbol}global_setter_i32_${index}`](val)
        }
      }
    }
  }
  return instance
}
1361894
def local_session(factory):
    """"""
    factory_region = getattr(factory, 'region', 'global')
    s = getattr(CONN_CACHE, factory_region, {}).get('session')
    t = getattr(CONN_CACHE, factory_region, {}).get('time')

    n = time.time()
    if s is not None and t + (60 * 45) > n:
        return s
    s = factory()

    setattr(CONN_CACHE, factory_region, {'session': s, 'time': n})
    return s
1040146
function createSession(){

    // can also check if any ealier session can be used
    if (!currentSession){
        
        const createNewSession = _setSessionReferrer();
        const currentSessionCookie = utils.getCookie(constants.sessionCookieName);

        if (currentSessionCookie && !createNewSession){

            const currentSessionSplit = currentSessionCookie.split('__');
            currentSession = new session(currentSessionSplit[0], 
                parseInt(currentSessionSplit[1]), {});
            
            logger.debug('Found existing session', currentSessionSplit[0], 
                currentSessionSplit[1]);

        } else{

            currentSession = new session(null, null, {});
            setSessionCookie();

            logger.debug('Creating new session', currentSession.getSessionToken(), 
                currentSession.getSessionUnixTime());

        }

        // associate session referrer with the session
        if (sessionReferrer){

            currentSession.setExtra('referrer', sessionReferrer);
            
        }
        
    }

    return currentSession;

}
901281
@Override
  public String initializeSession(JSONObject desiredCapabilities) {
    if (this.session != null) {
      session.getKnownElements().clear();
      return session.getSessionId();
    }
    activeWindowType = WindowType.NATIVE_APP.name();
    Random random = new Random();
    this.session =
        new Session(desiredCapabilities, new UUID(random.nextLong(), random.nextLong()).toString());
    nativeSearchScope =
        new NativeSearchScope(serverInstrumentation, getSession().getKnownElements());

    selendroidNativeDriver =
        new SelendroidNativeDriver(serverInstrumentation, (NativeSearchScope) nativeSearchScope);
    SelendroidLogger.info("new s: " + session.getSessionId());

    nativeExecuteScriptMap.put("invokeMenuActionSync", new InvokeMenuAction(session,
        serverInstrumentation));
    nativeExecuteScriptMap.put("findRId", new FindRId(serverInstrumentation));
    nativeExecuteScriptMap.put("getL10nKeyTranslation", new GetL10nKeyTranslation(
        serverInstrumentation));
    nativeExecuteScriptMap.put("findElementByAndroidTag",
        new FindElementByAndroidTag(session.getKnownElements(), serverInstrumentation, keySender));
    nativeExecuteScriptMap.put("isElementDisplayedInViewport", new IsElementDisplayedInViewport(
        session.getKnownElements(), serverInstrumentation));

    return session.getSessionId();
  }
1123073
private static synchronized void storeSingleton() {
        // recheck that we need to run because field could have been
        // set since we decided to invoke this method but before we acquired
        // the lock on this object
        if (PERSON_DIR_NAME_FINDER_INSTANCE == null) {
            IPersonAttributeDao personAttributeDao =
                    PersonAttributeDaoLocator.getPersonAttributeDao();
            PERSON_DIR_NAME_FINDER_INSTANCE = new PersonDirNameFinder(personAttributeDao);
        }
    }
765785
function Storage () {
  var self = this;

  self.klass = self.klass || Storage;

  var args = fun(arguments);

  self.url = args.strings().pop() || self.klass.url || null;
  self.options = args.objects().pop() || self.klass.options || {};

  self.client = null;
  self.ready = false;
  self.authorized = false;
  self.connecting = false;
  self.queue = [];

  if (self.id) {
    self.url = self.url && self.url.replace(/^([^\:]+)\:/gmi, self.protocol || self.id);
  }

  var uri = url.parse(self.url || '');

  self.options.server = self.options.server || {};
  self.options.server.protocol = uri.protocol && uri.protocol.replace(':', '');
  self.options.server.username = uri.auth && uri.auth.split(':')[0];
  self.options.server.password = uri.auth && uri.auth.split(':')[1];
  self.options.server.hostname = uri.hostname;
  self.options.server.port = uri.port && parseInt(uri.port, 10);
  self.options.server.db = uri.pathname;

  self.options.client = self.options.client || {};

  self.options = Object.merge(self.klass.defaults.options, self.options, true, false);
  self.options = JSON.parse(JSON.stringify(self.options)); // BUG/FIXME: Sugar.js bug?

  self.events = new Storage.EventEmitter();

  // self.on('error', function() {});

  self.on('connect', function() {
    self.ready = false;
    self.authorized = false;
    self.connecting = true;
  });

  self.on('ready', function(err) {
    if (!err) {
      self.ready = true;
      self.authorized = true;
      self.connecting = false;

      self._commit();
    }
  });

  self.on('end', function() {
    self.ready = false;
    self.authorized = false;
    self.connecting = false;
  });

  self.on('command', function(type, args) {
    self.emit(type, args);

    if (!self.ready) {
      self._push(type, args);
    }
  });

  process.on('exit', function() {
    sync(function() {
      if (typeof self.end === 'function') {
        self.end.sync(self);
      }
    });
  });

  process.on('uncaughtException', function() {
    sync(function() {
      if (typeof self.end === 'function') {
        self.end.sync(self);
      }
    });
  });
}
1310589
function storageInitialize() {
    var sessionStorage;
    /**
     * sessionStorage throws error when cookies are disabled
     * Chrome content settings when running the site in a Facebook IFrame.
     * see: https://github.com/devote/HTML5-History-API/issues/34
     * and: http://stackoverflow.com/a/12976988/669360
     */
    try {
      sessionStorage = global['sessionStorage'];
      sessionStorage.setItem(sessionStorageKey + 't', '1');
      sessionStorage.removeItem(sessionStorageKey + 't');
    } catch(_e_) {
      sessionStorage = {
        getItem: function(key) {
          var cookie = document.cookie.split(key + "=");
          return cookie.length > 1 && cookie.pop().split(";").shift() || 'null';
        },
        setItem: function(key, value) {
          var state = {};
          // insert one current element to cookie
          if (state[windowLocation.href] = historyObject.state) {
            document.cookie = key + '=' + JSON.stringify(state);
          }
        }
      }
    }

    try {
      // get cache from the storage in browser
      stateStorage = JSON.parse(sessionStorage.getItem(sessionStorageKey)) || {};
    } catch(_e_) {
      stateStorage = {};
    }

    // hang up the event handler to event unload page
    addEvent(eventNamePrefix + 'unload', function() {
      // save current state's object
      sessionStorage.setItem(sessionStorageKey, JSON.stringify(stateStorage));
    }, false);
  }
1074354
function mockLocalStorage() {
  global.localStorage = Object.defineProperties(
    {},
    {
      mockReset: { value: mockLocalStorage },
      removeItem: { value: jest.fn() },
      getItem: { value: jest.fn() },
      setItem: { value: jest.fn() },
      clear: { value: jest.fn() },
    }
  );
}
866989
private void saveSession(Session session) throws UnknownSessionException {
		if (session == null || session.getId() == null) {
			logger.error("session or session id is null");
			throw new UnknownSessionException("session or session id is null");
		}
		byte[] key;
		byte[] value;
		try {
			key = keySerializer.serialize(getRedisSessionKey(session.getId()));
			value = valueSerializer.serialize(session);
		} catch (SerializationException e) {
			logger.error("serialize session error. session id=" + session.getId());
			throw new UnknownSessionException(e);
		}
		if (expire == DEFAULT_EXPIRE) {
			this.redisManager.set(key, value, (int) (session.getTimeout() / MILLISECONDS_IN_A_SECOND));
			return;
		}
		if (expire != NO_EXPIRE && expire * MILLISECONDS_IN_A_SECOND < session.getTimeout()) {
			logger.warn("Redis session expire time: "
					+ (expire * MILLISECONDS_IN_A_SECOND)
					+ " is less than Session timeout: "
					+ session.getTimeout()
					+ " . It may cause some problems.");
		}
		this.redisManager.set(key, value, expire);
	}