diff --git a/src/flask_session/dynamodb/dynamodb.py b/src/flask_session/dynamodb/dynamodb.py index 9017dfdb..a7d4e3a0 100644 --- a/src/flask_session/dynamodb/dynamodb.py +++ b/src/flask_session/dynamodb/dynamodb.py @@ -144,7 +144,10 @@ def _create_table(self): def _retrieve_session_data(self, store_id: str) -> Optional[dict]: # Get the saved session (document) from the database document = self.store.get_item(Key={"id": store_id}).get("Item") - if document: + session_is_not_expired = Decimal(datetime.utcnow().timestamp()) <= document.get( + "expiration" + ) + if document and session_is_not_expired: serialized_session_data = want_bytes(document.get("val").value) return self.serializer.loads(serialized_session_data) return None