$ _session [''] = array ()

0

Where is the data saved in the session archived?

One more question, why is this code so

    if(!isset($_SESSION['itens'][$id])){
        $_SESSION['itens'][$id] = 1;
    }else{
        $_SESSION['itens'][$id] =1;
    }

I just copied this code from other people, but I do not know why they are together, so ['items'] [$ id]

Thank you very much.

    
asked by anonymous 04.05.2018 / 20:45

1 answer

1

The reason that the variable has two keys together as in its example $_SESSION['itens'][$id] means that the variable $_SESSION is an array and one of the fields in that array is itens . The variable then $_SESSION['itens'] is also an array and contains some fields within it, one being the value contained in the variable $id .

    
04.05.2018 / 20:56