MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / fetch_session

Method fetch_session

class/flask_session/sessions.py:640–660  ·  view source on GitHub ↗
(self, sid)

Source from the content-addressed store, hash-verified

638 self.sql_session_model = Session
639
640 def fetch_session(self, sid):
641 # Get the saved session (record) from the database
642 store_id = self.key_prefix + sid
643 record = self.sql_session_model.query.filter_by(session_id=store_id).first()
644
645 # If the expiration time is less than or equal to the current time (expired), delete the document
646 if record is not None:
647 expiration_datetime = record.expiry
648 if expiration_datetime is None or expiration_datetime <= datetime.utcnow():
649 self.db.session.delete(record)
650 self.db.session.commit()
651 record = None
652
653 # If the saved session still exists after checking for expiration, load the session data from the document
654 if record:
655 try:
656 session_data = self.serializer.loads(want_bytes(record.data))
657 return self.session_class(session_data, sid=sid)
658 except pickle.UnpicklingError:
659 return self.session_class(sid=sid, permanent=self.permanent)
660 return self.session_class(sid=sid, permanent=self.permanent)
661
662 def save_session(self, app, session, response):
663 if not self.should_set_cookie(app, session):

Callers

nothing calls this directly

Calls 4

firstMethod · 0.45
deleteMethod · 0.45
commitMethod · 0.45
loadsMethod · 0.45

Tested by

no test coverage detected