Save cookies to a file.
353927
def save_cache(data, filename):
    """"""
    with open(filename, 'wb') as handle:
        pickle.dump(data, handle)
715979
def StoreCSRFCookie(user, response):
  """"""

  csrf_token = GenerateCSRFToken(user, None)
  response.set_cookie(
      "csrftoken", csrf_token, max_age=CSRF_TOKEN_DURATION.seconds)
3153
def raw_cookies(self):
        ''''''
        cookie_data = self.environ.get('HTTP_COOKIE', '')
        cookies = SimpleCookie()
        if not cookie_data:
            return cookies
        cookies.load(cookie_data)
        return cookies
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),
        )
1200518
def append_cookie(self, cookie, name, payload, typ, domain=None, path=None,
                      timestamp="", max_age=0):
        
        timestamp = str(int(time.time()))

        # create cookie payload
        try:
            _payload = "::".join([payload, timestamp, typ])
        except TypeError:
            _payload = "::".join([payload[0], timestamp, typ])

        content = make_cookie_content(name, _payload, self.sign_key, domain=domain,
                                      path=path, timestamp=timestamp,
                                      enc_key=self.enc_key, max_age=max_age,
                                      sign_alg=self.sign_alg)

        for name, args in content.items():
            cookie[name] = args['value']
            for key, value in args.items():
                if key == 'value':
                    continue
                cookie[name][key] = value

        return cookie
655502
def set_cookie(self, cookie=None):
        """"""
        if cookie:
            self._cookie = cookie.encode()
        else:
            self._cookie = None
684280
def save_data(self):
        """"""
        filename = os.path.join(
            self._get_prefix(),
            self.model.site
        )
        self.store.store_json(
            filename,
            self.model.get_dict()
        )
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")
108264
def _save_file(self, filename, contents):
        """"""
        with open(filename, 'w') as f:
            f.write(contents)
762508
def __addcookies(self):
        '''
        '''
        for cname, morsel in self.cookies.items():
            attrs = []
            value = morsel.get('version', '')
            if value != '' and value != '0':
                attrs.append('$Version=%s' % value)
            attrs.append('%s=%s' % (cname, morsel.coded_value))
            value = morsel.get('path')
            if value:
                attrs.append('$Path=%s' % value)
            value = morsel.get('domain')
            if value:
                attrs.append('$Domain=%s' % value)
            self.h.putheader('Cookie', "; ".join(attrs))
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)
549406
def update(self, cookies):
    
    cookie_jar = self.get_cookie_jar()
    for cookie in cookies:
      cookie_jar.set_cookie(cookie)
    with self._lock:
      cookie_jar.save()
594150
def saveShp(self, target):
        """"""
        if not hasattr(target, "write"):
            target = os.path.splitext(target)[0] + '.shp'
        if not self.shapeType:
            self.shapeType = self._shapes[0].shapeType
        self.shp = self.__getFileObj(target)
        self.__shapefileHeader(self.shp, headerType='shp')
        self.__shpRecords()
581957
function cookieToHeader(cookies) {
    const SEPARATOR = '; ';
    return cookies.reduce(function (previous, current) {
        return previous + current.name + '=' + current.value + SEPARATOR;
    }, '');
}
1173042
def save(self, filename):
        """"""
        with open(filename, 'w') as fp:
            fp.write(str(self))
630429
def save(self):
        
        try:
            with open(self._filename, 'wb') as session_file:
                session_file.write(self.dumps())
        except IOError as error:
            LOGGER.error('Session file error: %s', error)
            raise error
868315
def saveFile(self):
        """"""
        filepath, _ = QtWidgets.QFileDialog.getSaveFileName(
            self, "Save File", '', "Androguard Session (*.ag)")

        if filepath:
            # Ensure .ag as file ending
            if not filepath.endswith(".ag"):
                filepath = "{}.ag".format(filepath)

            self.showStatus("Saving %s..." % str(filepath))
            self.saveSession(filepath)
            self.showStatus("Saved Session to %s!" % str(filepath))