def setCookie(self, value=None, expires=None, url='/', name=None, **args):
        u"""
        The ``setCookie`` method saves the cookie indicated by ``name`` with ``value``,
        using the ``expires`` and ``url`` attributes.
        """

        import datetime, urllib

        if not name:
            name = self.COOKIENAME

        # allow expires to be specified as number of days
        if expires and not isinstance(expires, basestring):
            try:
                days = int(expires)
                if days > 0:
                    expiry = datetime.datetime.now() + datetime.timedelta(days=days)
                    expires = expiry.strftime("%a, %d %b %Y %H:%M:%S GMT")
            except:
                expires = None

        # encode python objects into string
        value = urllib.quote(cjson.encode(value))

        self.request.addCookie(name, value, expires=expires, path=url, **args)

        # and just make sure it's available to the rest of this request
        self.request.received_cookies[name] = value
dataset/ETHPy150Open petrvanblokland/Xierpa3/xierpa3/descriptors/environment.py/Environment.setCookie/original