0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PHP: クッキーの使い方

Last updated at Posted at 2020-08-14

こちらと同様なことを、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_may0101.png

クッキーを確認

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>";
// ------------------------------------------------------------------
?>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?