Load the session from the store, by the id from cookie
(self)
| 97 | self._save() |
| 98 | |
| 99 | def _load(self): |
| 100 | """Load the session from the store, by the id from cookie""" |
| 101 | cookie_name = self._config.cookie_name |
| 102 | self.session_id = web.cookies().get(cookie_name) |
| 103 | # Handler can do session.send_cookie = False to not send the cookie |
| 104 | self.send_cookie = True |
| 105 | |
| 106 | # protection against session_id tampering |
| 107 | if self.session_id and not self._valid_session_id(self.session_id): |
| 108 | self.session_id = None |
| 109 | |
| 110 | self._check_expiry() |
| 111 | if self.session_id: |
| 112 | d = self.store[self.session_id] |
| 113 | self.update(d) |
| 114 | self._validate_ip() |
| 115 | |
| 116 | if not self.session_id: |
| 117 | self.session_id = self._generate_session_id() |
| 118 | |
| 119 | if self._initializer: |
| 120 | if isinstance(self._initializer, dict): |
| 121 | self.update(deepcopy(self._initializer)) |
| 122 | elif hasattr(self._initializer, "__call__"): |
| 123 | self._initializer() |
| 124 | |
| 125 | self.ip = web.ctx.ip |
| 126 | |
| 127 | def _check_expiry(self): |
| 128 | # check for expiry |
no test coverage detected