$_Session [ ' ' ] = array ( )

Asked

Viewed 103 times

0

Where the data saved in Session is stored?

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 don’t know why they’re together like [ ' items' ] [ $id ]

Hug, thanks in advance .

  • If there is no key $_SESSION['itens'][$id] the code creates it and assigns the value 1, if any assigns the value 1 also :)

  • Friend, try to be a little more explanatory in your question. What is the purpose of the function you want to use? Also change the title to something we can understand

  • of a read in: session_save_path available in: http://php.net/manual/en/function.session-savepath.php

1 answer

1

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.