equal
deleted
inserted
replaced
567 try: |
567 try: |
568 return SimpleCookie(self.get_header('Cookie')) |
568 return SimpleCookie(self.get_header('Cookie')) |
569 except KeyError: |
569 except KeyError: |
570 return SimpleCookie() |
570 return SimpleCookie() |
571 |
571 |
572 def set_cookie(self, name, value, maxage=300, expires=None, secure=False): |
572 def set_cookie(self, name, value, maxage=300, expires=None, secure=False, httponly=False): |
573 """set / update a cookie |
573 """set / update a cookie |
574 |
574 |
575 by default, cookie will be available for the next 5 minutes. |
575 by default, cookie will be available for the next 5 minutes. |
576 Give maxage = None to have a "session" cookie expiring when the |
576 Give maxage = None to have a "session" cookie expiring when the |
577 client close its browser |
577 client close its browser |
593 expires = timegm((expires + GMTOFFSET).timetuple()) |
593 expires = timegm((expires + GMTOFFSET).timetuple()) |
594 else: |
594 else: |
595 expires = None |
595 expires = None |
596 # make sure cookie is set on the correct path |
596 # make sure cookie is set on the correct path |
597 cookie = Cookie(str(name), str(value), self.base_url_path(), |
597 cookie = Cookie(str(name), str(value), self.base_url_path(), |
598 expires=expires, secure=secure) |
598 expires=expires, secure=secure, httponly=httponly) |
599 self.headers_out.addHeader('Set-cookie', cookie) |
599 self.headers_out.addHeader('Set-cookie', cookie) |
600 |
600 |
601 def remove_cookie(self, name, bwcompat=None): |
601 def remove_cookie(self, name, bwcompat=None): |
602 """remove a cookie by expiring it""" |
602 """remove a cookie by expiring it""" |
603 if bwcompat is not None: |
603 if bwcompat is not None: |