'Attempts to return a signed cookie. If the signature fails or the
cookie has expired, raises an exception... unless you provide the
default argument in which case that value will be returned instead.'

def get_signed_cookie(self, key, default=RAISE_ERROR, salt=u'', max_age=None):

    try:
        cookie_value = self.COOKIES[key]
    except KeyError:
        if (default is not RAISE_ERROR):
            return default
        else:
            raise
    try:
        value = signing.get_cookie_signer(salt=(key + salt)).unsign(cookie_value, max_age=max_age)
    except signing.BadSignature:
        if (default is not RAISE_ERROR):
            return default
        else:
            raise
    return value
