看了flask的session源碼,知道了flask的sessionflask
flask的open_session源碼cookie
class SecureCookieSessionInterface(SessionInterface): ..... def open_session(self, app, request): s = self.get_signing_serializer(app) if s is None: return None val = request.cookies.get(app.session_cookie_name) if not val: return self.session_class() max_age = total_seconds(app.permanent_session_lifetime) try: data = s.loads(val, max_age=max_age) return self.session_class(data) except BadSignature: return self.session_class() .....
能夠從源碼中看出,session中存放了 life_time 因此能夠根據這個存活時間進行session過濾。session