Code Duplication    Length = 18-21 lines in 2 locations

htdocs/lib/cookie.class.php 1 location

@@ 17-34 (lines=18) @@
14
    public $changed = false;
15
    public $values = array();
16
17
    public function __construct()
18
    {
19
        global $opt;
20
21
        if (isset($_COOKIE[$opt['cookie']['name'] . 'data'])) {
22
            //get the cookievars-array
23
            $decoded = base64_decode($_COOKIE[$opt['cookie']['name'] . 'data']);
24
25
            if ($decoded !== false) {
26
                $this->values = @unserialize($decoded);
27
                if (!is_array($this->values)) {
28
                    $this->values = array();
29
                }
30
            } else {
31
                $this->values = array();
32
            }
33
        }
34
    }
35
36
    public function set($name, $value)
37
    {

htdocs/src/Oc/Session/SessionDataCookie.php 1 location

@@ 21-41 (lines=21) @@
18
    /**
19
     * SessionDataCookie constructor.
20
     */
21
    public function __construct()
22
    {
23
        global $opt;
24
25
        if (isset($_COOKIE[$opt['session']['cookiename'] . 'data'])) {
26
            //get the cookievars-array
27
            $decoded = base64_decode($_COOKIE[$opt['session']['cookiename'] . 'data'], true);
28
29
            if ($decoded !== false) {
30
                // TODO replace by safe function
31
                $this->values = @unserialize($decoded); // bad
32
                //$this->values = @json_decode($decoded, true); // safe
33
                //print_r($this->values);
34
                if (!is_array($this->values)) {
35
                    $this->values = [];
36
                }
37
            } else {
38
                $this->values = [];
39
            }
40
        }
41
    }
42
43
    /**
44
     * @param $name