MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / save_session

Method save_session

web/pgadmin/utils/session.py:456–484  ·  view source on GitHub ↗
(self, app, session, response)

Source from the content-addressed store, hash-verified

454 return self.manager.new_session()
455
456 def save_session(self, app, session, response):
457 domain = self.get_cookie_domain(app)
458 if not session:
459 self.manager.remove(session.sid)
460 if session.modified:
461 response.delete_cookie(app.config['SESSION_COOKIE_NAME'],
462 domain=domain)
463 return
464
465 if not session.modified:
466 # No need to save an unaltered session
467 # TODO: put logic here to test if the cookie is older than N days,
468 # if so, update the expiration date
469 return
470
471 self.manager.put(session)
472 session.modified = False
473
474 cookie_exp = self.get_expiration_time(app, session)
475 response.set_cookie(
476 app.config['SESSION_COOKIE_NAME'],
477 '%s!%s' % (session.sid, session.hmac_digest),
478 expires=cookie_exp,
479 path=config.SESSION_COOKIE_PATH,
480 secure=config.SESSION_COOKIE_SECURE,
481 httponly=config.SESSION_COOKIE_HTTPONLY,
482 samesite=config.SESSION_COOKIE_SAMESITE,
483 domain=domain
484 )
485
486
487def create_session_interface(app, skip_paths=[]):

Callers 1

generate_csrf_tokenMethod · 0.80

Calls 4

delete_cookieMethod · 0.80
set_cookieMethod · 0.80
removeMethod · 0.45
putMethod · 0.45

Tested by 1

generate_csrf_tokenMethod · 0.64