Main page
$_SESSION['uniqid_mt_rand'] = uniqid(mt_rand(), true);
Then input form
<input name="hidden_field" type="hidden" id="hidden_field"
value="<?php echo htmlspecialchars( $_SESSION['uniqid_mt_rand'] , ENT_QUOTES, "UTF-8");?>">
Then with $.post("_record_comments.php" ....
send to _record_comments.php
And in _record_comments.php
check if
$_SESSION['uniqid_mt_rand'] == $_POST['hidden_field']
Does it help to prevent something? As understand in this case I can be sure, that form is filled from website. So if bot send 'form' $_POST
and $_SESSION
would not be the same?