Home  >  Article  >  Backend Development  >  After I stored the session in the database, a problem occurred when reading all session information?

After I stored the session in the database, a problem occurred when reading all session information?

WBOY
WBOYOriginal
2016-09-11 11:34:141121browse

This is the code

<code>function get() {
        session_start();
        $data = $this->db->fetchAll("SELECT * FROM session");
        foreach ($data as $key => &$value) {
            $need = stripcslashes($value['session_data']);
            session_decode($need);
            $value['session_data'] = $_SESSION;
        }
        var_dump($data);

    }

    private function copyArr($arr) {
        $copyArr = [];
        foreach ($arr as $key => $value) {
            $copyArr[$key] = $value;
        }
        return $copyArr;
    }
</code>

After I stored the session in the database, a problem occurred when reading all session information?
After I called the copyArr function: (The result is different)

After I stored the session in the database, a problem occurred when reading all session information?

After I stored the session in the database, a problem occurred when reading all session information?

Reply content:

This is the code

<code>function get() {
        session_start();
        $data = $this->db->fetchAll("SELECT * FROM session");
        foreach ($data as $key => &$value) {
            $need = stripcslashes($value['session_data']);
            session_decode($need);
            $value['session_data'] = $_SESSION;
        }
        var_dump($data);

    }

    private function copyArr($arr) {
        $copyArr = [];
        foreach ($arr as $key => $value) {
            $copyArr[$key] = $value;
        }
        return $copyArr;
    }
</code>

After I stored the session in the database, a problem occurred when reading all session information?
After I called the copyArr function: (The result is different)

After I stored the session in the database, a problem occurred when reading all session information?

After I stored the session in the database, a problem occurred when reading all session information?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn