问题
How do I only allow one POST per browser session?
回答1:
<?php
session_start();
if (isset($_SESSION['already_posted'])) {
echo "Already posted.";
exit();
}
$is_valid_post = isset($_POST['txt_udid']); // && validate stuff...;
//... process $_POST....
if ($is_valid_post) {
$_SESSION['already_posted'] = 1;
}
回答2:
save information into $_SESSION after handling submission, and at the beginning of handling submission check if any information were previously saved in $_SESSION.
来源:https://stackoverflow.com/questions/12100521/how-do-i-only-allow-one-post-per-browser-session