PHP: クッキーの使い方


こちらと同様なことを、PHP で行いました。
jquery-cookie の使い方
Perl: クッキーの使い方

クッキーを送る

cookie_put.php
<?php
// ------------------------------------------------------------------
//
//  cookie_put.php
//
setcookie('message','これはテストです。by PHP',['samesite' => 'None', 'secure' =
> true]);
setcookie('aa','りんご by PHP',['samesite' => 'None', 'secure' => true]);
setcookie('bb','ぶどうby PHP',['samesite' => 'None', 'secure' => true]);
setcookie('cc','桃 by PHP',['samesite' => 'None', 'secure' => true]);

echo "<!DOCTYPE html>";
echo "<html lang=\"ja\">";
echo "<body>";

echo "Aug/14/2020<p/>";
echo "</body>";
echo "</html>";
// ------------------------------------------------------------------
?>

クッキーを確認

cookie_get.php
<?php
// ------------------------------------------------------------------
//
//  cookie_get.php
//
echo "<!DOCTYPE html>";
echo "<html lang=\"ja\">";
echo "<body>";
echo "message: " . $_COOKIE['message'] . "<br />";
echo "aa: " . $_COOKIE['aa'] . "<br />";
echo "bb: " . $_COOKIE['bb'] . "<br />";
echo "cc: " . $_COOKIE['cc'] . "<br />";

echo "Aug/14/2020<p/>";
echo "</body>";
echo "</html>";
// ------------------------------------------------------------------
?>