diff --git a/examples/set_sessions.py b/examples/set_sessions.py new file mode 100644 index 00000000..0d04138f --- /dev/null +++ b/examples/set_sessions.py @@ -0,0 +1,19 @@ +# -*- encoding: utf-8 -*- + +from sanic import Sanic +from sanic.response import json + +app = Sanic() + + +@app.route("/") +async def test(request): + if request.session.get('key') is None: + request.session['key'] = 'value' + return json(dict(ok=True)) + else: + return json(dict(key=request.session['key'])) + + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8000) diff --git a/sanic/sessions.py b/sanic/sessions.py index 697286cd..1de951d9 100644 --- a/sanic/sessions.py +++ b/sanic/sessions.py @@ -289,7 +289,7 @@ class SecureCookieSessionInterface(SessionInterface): if not self.should_set_cookie(app, session): return httponly = self.get_cookie_httponly(app) - secure = self.get_cookie_secure(app) + # secure = self.get_cookie_secure(app) expires = self.get_expiration_time(app, session) val = self.get_signing_serializer(app).dumps(dict(session)) session_cookie_name = app.config.SESSION_COOKIE_NAME @@ -300,4 +300,4 @@ class SecureCookieSessionInterface(SessionInterface): if domain: response.cookies[session_cookie_name]["domain"] = domain response.cookies[session_cookie_name]["path"] = path - response.cookies[session_cookie_name]["secure"] = secure + # response.cookies[session_cookie_name]["secure"] = secure