protected function startSession() { if ($this->session !== null) { $this->session->destroy(); } $this->session = $this->session_pool->get(); $this->updateSessionData(); $this->token = $this->session->getId(); $this->session_entry = new SessionEntry(); $this->session_entry->setToken($this->token); $this->session_entry->setModelId($this->user->getId()); $this->session_entry->setModelName(get_class($this->user)); if ($this->options['application']) { $this->session_entry->setApplication($this->application); } $lifetime = $this->token_handler->getTokenLifetime() + $this->options['update_gap']; $expired_at = (new \DateTime())->modify('+' . $lifetime . ' second'); $this->session_entry->setExpiredAt($expired_at); $this->session_entry->save(); }