What’s the difference between HTTP_COOKIE_VARS and _COOKIE ?

Why does $_COOKIE works on GoDaddy and $HTTP_COOKIE_VARS dont? :shifty:


Note: Introduced in 4.1.0. In earlier versions, use $HTTP_COOKIE_VARS.

An associative array of variables passed to the current script via HTTP cookies. Automatically global in any scope.

This is a ‘superglobal’, or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don’t need to do a global $_COOKIE; to access it within functions or methods, as you do with $HTTP_COOKIE_VARS.

$HTTP_COOKIE_VARS contains the same initial information, but is not a superglobal. (Note that HTTP_COOKIE_VARS and _COOKIE are different variables and that PHP handles them as such)

HTTP_* variables are deprecated. They were the autoglobals of PHP a loooooong time ago and are only included as a configuration option today for historical purposes. The new standard are the _COOKIE, _POST, _GET, _SERVER, _REQUEST variables.

There is no difference between the two except that the latter is the standard way and the former is the deprecated way.

The reason that $HTTP_* vars don’t work on many servers is because it is a PHP option to enable them and, living up to the new standard, many don’t.