| 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 | |
| 487 | def create_session_interface(app, skip_paths=[]): |