Skip to content

Instantly share code, notes, and snippets.

@k4200
Created May 14, 2011 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k4200/971975 to your computer and use it in GitHub Desktop.
Save k4200/971975 to your computer and use it in GitHub Desktop.
CSFR対策
<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