symfony 4.4获取会话ID,并根据匹配的会话ID删除mariadb中的记录

问题描述

会话ID是“会话”表和另一个表“ temp_sessions”中的主键 注销后,将调用logout.php文件,并执行以下部分。 如何编写SQL查询以匹配主键(在本例中为会话ID),然后将其从另一个SQL表中删除?


         */
    public function logout(MyUser $user)
    {
        $url = $this->getServiceUrl(__FUNCTION__);

        try {
            $this->logger->debug("SERVICE CALLED | Url: $url");
            $response = $this->getClient()->post($url,[
                'json' => [
                    'session_id' => $user->getSessionId(),]
            ]);

            $real_session_id = $request->getSession()->get('_session_id');
            $sess_id = $request->getSession()->getId();
 
            // get the session id here and delete a record in the mariadb***

        } catch (\Throwable $exception) {
            $this->logger->critical("SERVICE EXCEPTION | Url: $url | Exception: " . $exception->getMessage());
            throw new ServiceException($exception->getMessage());
        }

        $content = $response->getBody()->getContents();
        $content = json_decode($content,true);

        if ('failure' === $content['result']) {
            $this->logger->error("SERVICE FAILURE | Url: $url | Message: {$content['message']}");
            throw new ServiceException($content['message']);
        }

        return $content;
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...