When creating a form, you can use:
<?php session_start();
You need to check when someone sends a message that the mail request has the correct hash. You can use:
<?php session_start(); // don't forget that you need to call before output (place first, or use ob_start() if (isset($_SESSION['formhash']) && isset($_POST['hash']) && $_SESSION['formhash']==$_POST['hash']) { // treat $_POST } ?>
source share