Created
May 14, 2011 06:14
-
-
Save k4200/971975 to your computer and use it in GitHub Desktop.
CSFR対策
This file contains 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
<form name="aa" action="foo.php" method="POST"> | |
<input type='text' name='important_info' /> | |
<input type='hidden' name='token' value='<?php echo session_id(); ?>' /> | |
<input type='submit' name='submit' value='send it' /> | |
</form> | |
----- | |
<!-- 次のページ foo.php --> | |
<?php | |
session_start(); | |
if (session_id() !== $_POST['token']) { | |
// error | |
header('Location: /error.html'); //リダイレクトさせたり | |
die('やめて下さい!'); //エラーメッセージを表示する | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment