Python 为CherryPy';s会议
我正在用CherryPy编写一个软件。我正在使用普通会话,使用“cherrypy.session”。 现在我注意到Firefox抱怨我使用了“错误的”samesite属性,并且它可能在将来不再可用Python 为CherryPy';s会议,python,cookies,cherrypy,Python,Cookies,Cherrypy,我正在用CherryPy编写一个软件。我正在使用普通会话,使用“cherrypy.session”。 现在我注意到Firefox抱怨我使用了“错误的”samesite属性,并且它可能在将来不再可用 有没有办法将CherryPy会话cookies的samesite属性设置为另一个值?这有点棘手,因为已经讨论过多次(例如,look) 这意味着python
有没有办法将CherryPy会话cookies的samesite属性设置为另一个值?这有点棘手,因为已经讨论过多次(例如,look) 这意味着python<3.8显然没有解决方案。 但是,您仍然可以使用monkeypatch。 因此,请执行以下操作以解决问题:
from http import cookies
cookies.Morsel._reserved.setdefault('samesite', 'SameSite')
def init(storage_type=None, path=None, path_header=None, name='session_id',
timeout=60, domain=None, secure=False, clean_freq=5,
persistent=True, httponly=False, debug=False,
# Py27 compat
# *, storage_class=RamSession,
**kwargs):
set_response_cookie(path=path, path_header=path_header, name=name,
timeout=cookie_timeout, domain=domain, secure=secure,
httponly=httponly)
def set_response_cookie(path=None, path_header=None, name='session_id',
timeout=60, domain=None, secure=False, httponly=False):
set_response_cookie(path=path, path_header=path_header, name=name,
timeout=cookie_timeout, domain=domain, secure=secure,
httponly=httponly)
def set_response_cookie(path=None, path_header=None, name='session_id',
timeout=60, domain=None, secure=False, httponly=False):
'tools.sessions.samesite': 'strict'
或
祝你好运
if samesite in ['lax', 'strict', None]:
cookie[name]['samesite'] = str(samesite)
'tools.sessions.samesite': 'strict'
'tools.sessions.samesite': 'lax' # This is the default value