semantic-portal Semantic portal
Main Courses Domains Terminology About
Predefined Variables

$_COOKIE

Domains: PHP

(PHP 4 >= 4.1.0, PHP 5, PHP 7)

$_COOKIE -- $HTTP_COOKIE_VARS [deprecated] — HTTP Cookies

Description

An associative array of variables passed to the current script via HTTP Cookies.

$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)

Changelog

Version Description
4.1.0 Introduced $_COOKIE that deprecated $HTTP_COOKIE_VARS.

Examples

Example #1 $_COOKIE example

<?php
echo 'Hello ' . htmlspecialchars($_COOKIE["name"]) . '!';
?>

Assuming the "name" cookie has been set earlier

The above example will output something similar to:

Hello Hannes!

Notes

Note:

This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods.

See Also

  • setcookie() - Send a cookie
  • Handling external variables
  • The filter extension

Similar pages

ssh2://

$argv

$argc

Page structure
Concept map →
Terms

Variables in PHP

Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive. Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

PHP

Is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML

PHP tags

When PHP parses a file, it looks for opening and closing tags, which are <?php and ?> which tell PHP to start and stop interpreting the code between them.
Semantic portal semantic-portal.net Copyright © 2010—2023 When using materials
requires a link to semantic-portal.net
Main Courses Domains
Terminology About Partnership
Search
Ontology portals
research team.
APEPS department
of Igor Sikorsky KPI