クッキーの例え

このコミットが含まれているのは:
守矢諏訪子 2022-03-30 20:14:51 +09:00
コミット e22731c8ce
3個のファイルの変更26行の追加2行の削除

ファイルの表示

@ -1,9 +1,9 @@
<?php
function getcookie (string $name): array {
function getcookie (string $name): string {
return htmlspecialchars($_COOKIE[$name]);
}
function getrawcookie (string $name): array {
function getrawcookie (string $name): string {
return $_COOKIE[$name];
}
?>

15
src/cookie/index.php ノーマルファイル
ファイルの表示

@ -0,0 +1,15 @@
<?php
if (isset($_POST['lolicon_cookie'])) {
// 2時間後消えられます。
setcookie('lolicon_cookie', $_POST['lolicon_cookie'], ['expires' => time()+60*60*2, 'path' => '/cookie', 'httponly' => true]);
//setrawcookie('lolicon_cookie', $_POST['lolicon_cookie'], ['expires' => time()+60*60*2, 'path' => '/cookie', 'httponly' => true]);
header('Location: /cookie', 301);
}
$title = 'クッキー'; // 必須・Requirement
$sitedesc = 'クッキーの例え'; // config.phpの文字の交換・Change character of config.php
$siteurl .= '/cookie'; // config.phpの文字に追加・Add to character of config.php
$childview = '../ui/cookie/index.php'; // 必須・Requirement
$mycookie = getcookie('lolicon_cookie');
//$mycookie = getrawcookie('lolicon_cookie');
?>

9
ui/cookie/index.php ノーマルファイル
ファイルの表示

@ -0,0 +1,9 @@
setcookie
<form method="POST" action="/cookie">
<input type="text" name="lolicon_cookie" />
<input type="submit" value="送信" />
</form>
<hr />
getcookie
<?php echo $mycookie; ?>