192k views
1 vote
Which of the following that can be use read cookies in PHP?

Select one:

a. $_COOKIE

b. $_COOKIES

c. setcookie()

d. cookie()

1 Answer

0 votes

Answer:

a. $_COOKIE

Step-by-step explanation:

$_COOKIE represents an associative array of Cookie name and value in PHP. For example in the code below we use the $_COOKIE construct to read the value of a cookie called 'testcookie' provided it has already been set.

<html>

<body>

<?php

if(!isset($_COOKIE["testcookie"])) {

echo "Cookie 'testcookie' is not defined!";

} else {

echo "Value of 'testcookie' is: " . $_COOKIE["testcookie"];

}

?>

</body>

</html>

User Bart Pelle
by
4.7k points