Created
August 28, 2011 13:13
-
-
Save ts-3156/1176650 to your computer and use it in GitHub Desktop.
Java SE6のCookieHandlerを使うサンプル。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
サーバが送ったCookie、クライアントが送ったCookieを表示するサンプル。 | |
このファイルにJavaからアクセスすることで、Cookieの値を確認しながらデバッグができる | |
--> | |
<?php | |
$cookie_name = '名前'; | |
$cookie_value = '値'; | |
setcookie($cookie_name, $cookie_value); | |
?> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
</head> | |
<body> | |
<div>GET、POSTパラメータ一覧</div> | |
<?php | |
foreach( $_GET as $key => $value ) { | |
echo "GET " . htmlspecialchars($key) . "=" . htmlspecialchars($value) . "<br>\n"; | |
} | |
foreach( $_POST as $key => $value ) { | |
echo "POST " . htmlspecialchars($key) . "=" . htmlspecialchars($value) . "<br>\n"; | |
} | |
?> | |
<br> | |
<div>サーバから送ったCookie</div> | |
<?php | |
echo "name=" . $cookie_name . ", value=" . $cookie_value . "<br>\n"; | |
?> | |
<br> | |
<div>クライアントから送られたCookie</div> | |
<?php | |
foreach( $_COOKIE as $key => $value ) { | |
echo "Cookie " . htmlspecialchars($key) . "=" . htmlspecialchars($value) . "<br>\n"; | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment