'Convenience method for setting a session cookie'

def set_cookie(self, value, name='galaxysession', path='/', age=90, version='1'):

    self.response.cookies[name] = value
    self.response.cookies[name]['path'] = path
    self.response.cookies[name]['max-age'] = ((3600 * 24) * age)
    tstamp = time.localtime((time.time() + ((3600 * 24) * age)))
    self.response.cookies[name]['expires'] = time.strftime('%a,    %d-%b-%Y    %H:%M:%S    GMT', tstamp)
    self.response.cookies[name]['version'] = version
    https = (self.request.environ['wsgi.url_scheme'] == 'https')
    if https:
        self.response.cookies[name]['secure'] = True
    try:
        self.response.cookies[name]['httponly'] = True
    except CookieError as e:
        log.warning(("Error    setting    httponly    attribute    in    cookie    '%s':    %s" % (name, e)))
