Save androguard session.
191897
def saveSession(self, filepath):
        """"""
        try:
            session_module.Save(self.session, filepath)
        except RuntimeError as e:
            log.exception(e)
            os.remove(filepath)
            log.warning("Session not saved")
1252907
def save(self):
        """"""
        try:
            os.makedirs(os.path.dirname(self._configfile))
        except:
            pass

        with open(self._configfile, 'w') as f:
            self._config.write(f)
861512
function saveOldSessions() {
    var db = self.store;
    var oldDestroy = db.destroy;
    db.destroy = newDestroy;
    return;

    // rename instead of delete
    function newDestroy(sid, cb) {
      db.get(sid, function(err, session) {
        if (err) return cb(err);
        if (!session) return cb();
        db.set(sid + '_d', session, function(err) {
          if (err) return cb(err);
          oldDestroy.call(db, sid, cb);
        });
      });
    }
  }
762632
public function save():bool
    {
        $_SESSION = $this->session;
        return (0 === count(array_diff($this->session, $_SESSION)))? true : false;
    }
666504
private void saveToSession(HttpServletRequest req, String reqURL, Map params) {
		HttpSession postparamsession = req.getSession(true);
		if (postparamsession != null && params != null && !params.isEmpty()) {
			postparamsession.setAttribute(INITIAL_URL, reqURL);
			postparamsession.setAttribute(PARAM_NAMES, null);
			postparamsession.setAttribute(PARAM_VALUES, params);
			if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
				Tr.debug(tc, "URL saved: " + reqURL.toString());
			}
		}
	}
684280
def save_data(self):
        """"""
        filename = os.path.join(
            self._get_prefix(),
            self.model.site
        )
        self.store.store_json(
            filename,
            self.model.get_dict()
        )
73354
async def save_session(  # type: ignore
            self, app: 'Quart', session: SecureCookieSession, response: Response,
    ) -> None:
        """"""
        domain = self.get_cookie_domain(app)
        path = self.get_cookie_path(app)
        if not session:
            if session.modified:
                response.delete_cookie(app.session_cookie_name, domain=domain, path=path)
            return

        if session.accessed:
            response.vary.add('Cookie')

        if not self.should_set_cookie(app, session):
            return

        data = self.get_signing_serializer(app).dumps(dict(session))
        response.set_cookie(
            app.session_cookie_name,
            data,
            expires=self.get_expiration_time(app, session),
            httponly=self.get_cookie_httponly(app),
            domain=domain,
            path=path,
            secure=self.get_cookie_secure(app),
        )
1105819
public function save() {
    $this->logger->info('%name started.', ['%name' => get_class($this)]);
    $this->wrapper->setSavedHashes();

    $data = $this->wrapper->getDataToCreate();
    if (empty($data)) {
      $this->logger->info('%name finished. Nothing new to create.', ['%name' => get_class($this)]);
    }

    foreach ($data as $locationId => $locationData) {
      foreach ($locationData as $classId => $classItems) {
        foreach ($classItems as $class) {

          try {
            $session = $this->createSession($class);
            $mapping = $this->entityTypeManager->getStorage('openy_pef_gxp_mapping')->create(
              [
                'session' => $session,
                'product_id' => $classId,
                'location_id' => $locationId,
              ]
            );
            $mapping->save();
          }
          catch (Exception $exception) {
            $this->logger
              ->error(
                'Failed to create a session with error message: @message',
                ['@message' => $exception->getMessage()]
              );
            continue;
          }
        }
      }
    }
    $this->logger->info('%name finished.', ['%name' => get_class($this)]);
  }
921659
public function save_session(): self
  {
    $id_session = $this->get_id_session();
    //die(var_dump($id_session, $this->check()));
    if ( $id_session && $this->check() ){
      $p =& $this->class_cfg['arch']['sessions'];
      $this->db->update($this->class_cfg['tables']['sessions'], [
        $p['id_user'] => $this->id,
        $p['sess_id'] => $this->session->get_id(),
        $p['ip_address'] => $this->ip_address,
        $p['user_agent'] => $this->user_agent,
        $p['opened'] => 1,
        $p['last_activity'] => date('Y-m-d H:i:s'),
        $p['cfg'] => json_encode($this->sess_cfg)
      ], [
        $p['id'] => $id_session
      ]);
    }
    else{
      $this->set_error(13);
    }
    return $this;
  }
783782
def save(self):
        
        with open(self.filename, 'w') as f:
            ujson.dump(self.config, f, indent=4)
1136641
async def save(self, request, response):
        """"""
        if isinstance(response, Response) and SESSION_KEY in request and not response.prepared:
            session = request[SESSION_KEY]
            if session.save(response.set_cookie):
                self.app.logger.debug('Session saved: %s', session)
431980
def save(self):
        
        try:
            if self.exists() is False:
                self.db.session.add(self)
            # self.db.session.merge(self)
            self.db.session.commit()
        except (Exception, BaseException) as error:
            if current_app.config['DEBUG']:
                raise error
            return None
316480
def androlyze_main(session, filename):
    
    from androguard.core.androconf import ANDROGUARD_VERSION, CONF
    from IPython.terminal.embed import InteractiveShellEmbed
    from traitlets.config import Config
    from androguard.misc import init_print_colors
    from androguard.session import Session, Load
    from colorama import Fore
    import colorama
    import atexit

    # Import commonly used classes, for further usage...
    from androguard.core.bytecodes.apk import APK
    from androguard.core.bytecodes.dvm import DalvikVMFormat
    from androguard.core.analysis.analysis import Analysis

    colorama.init()

    if session:
        print("Restoring session '{}'...".format(session))
        s = CONF['SESSION'] = Load(session)
        print("Successfully restored {}".format(s))
        # TODO Restore a, d, dx etc...
    else:
        s = CONF["SESSION"] = Session(export_ipython=True)

    if filename:
        ("Loading apk {}...".format(os.path.basename(filename)))
        print("Please be patient, this might take a while.")

        filetype = androconf.is_android(filename)

        print("Found the provided file is of type '{}'".format(filetype))

        if filetype not in ['DEX', 'DEY', 'APK']:
            print(Fore.RED + "This file type is not supported by androlyze for auto loading right now!" + Fore.RESET, file=sys.stderr)
            print("But your file is still available:")
            print(">>> filename")
            print(repr(filename))
            print()

        else:
            with open(filename, "rb") as fp:
                raw = fp.read()

            h = s.add(apk, raw)
            print("Added file to session: SHA256::{}".format(h))

            if filetype == 'APK':
                print("Loaded APK file...")
                a, d, dx = s.get_objects_apk(digest=h)

                print(">>> a")
                print(a)
                print(">>> d")
                print(d)
                print(">>> dx")
                print(dx)
                print()
            elif filetype in ['DEX', 'DEY']:
                print("Loaded DEX file...")
                for h_, d, dx in s.get_objects_dex():
                    if h == h_:
                        break
                print(">>> d")
                print(d)
                print(">>> dx")
                print(dx)
                print()

    def shutdown_hook():
        """Save the session on exit, if wanted"""
        if not s.isOpen():
            return

        try:
            res = input("Do you want to save the session? (y/[n])?").lower()
        except (EOFError, KeyboardInterrupt):
            pass
        else:
            if res == "y":
                # TODO: if we already started from a session, probably we want to save it under the same name...
                # TODO: be able to take any filename you want
                fname = s.save()
                print("Saved Session to file: '{}'".format(fname))

    cfg = Config()
    _version_string = "Androguard version {}".format(ANDROGUARD_VERSION)
    ipshell = InteractiveShellEmbed(config=cfg, banner1="{} started"
                                    .format(_version_string))
    atexit.register(shutdown_hook)
    init_print_colors()
    ipshell()
1082767
def keep_session_alive(self):
        """"""

        try:
            self.resources()
        except xmlrpclib.Fault as fault:
            if fault.faultCode == 5:
                self.login()
            else:
                raise
456507
async def save_session(self, sid, session):
        
        socket = self._get_socket(sid)
        socket.session = session
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());
		}
		
	}
1111815
def save(self):
        """"""
        file_name = fd.asksaveasfilename()
        if file_name is "" or file_name is None:
            return
        with open(file_name, "w") as f:
            f.write(self.text.get("1.0", tk.END))