Write the following content into the cookie, get the content from the cookie, and print it to the page
Reference renderings:
Task
(Data: imooc's name 'IMOOC', imooc's password '123456' imooc's email '[email protected]')
1. Write the content into the cookie and create an array
2. Detect whether the cookie exists, and print it if it exists (isset can be used)
3. Traverse the obtained cookie to the page
1 <? php 2 // write cookie 3 $name = setcookie ('name','IMOOC' ); 4 $pwd = setcookie ('pwd','123456' ); 5 $email = setcookie ('email', '[email protected]' ); 6 // $arr=[]; 7 8 9 //Check if cookie is set, output 10 if set // for($i=0;$i<count($_COOKIE); $i++){ 11 // echo 12 // } 13 // isset() 14 foreach ( $_COOKIE as $key=>$value){ 15 if(isset($_COOKIE[$key])){ 16 echo $key.":".$value.'<br>'; 17 } 18 } 19 20 ?>