Search code examples
phpphp-extension

_COOKIE Info on the server Side


I want to get the cookie information stored using setcookie function in the source code of the php.. not the php source code.. What is the corresponding C code for _COOKIE['xx'];

In other words where is the _COOKIE array created and populated?


Solution

  • The $_COOKIE variable doesn't use JIT (just-in-time initialization), so it's always accessible by reading the global variables table EG(symbol_table):

    zval **cookie_var;
    if (zend_hash_find(&EG(symbol_table), "_COOKIE", sizeof("_COOKIE"),
            (void**)&cookie_var) == SUCCESS) {
        /* do something with cookie_var */
    } else {
        /* handle error; shouldn't happen */
    }