开发者

_COOKIE Info on the server Side

开发者 https://www.devze.com 2023-01-14 08:38 出处:网络
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\'];

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?


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 */
}


Cookie info comes as part of your http headers (that the browser sends). PHP makes it easier to access them by parsing it out in to a neat array and putting it in _COOKIE. You'll have to do it in C.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号