a) setcookie() DEVE APARECER antes da tag html.
https://www.w3schools.com/php/php_cookies.asp
b) file_exists — Verifica se um arquivo ou diretório existe
bool file_exists ( string $filename );
d) PHP Filters
Validating data = Determine if the data is in proper form.
Sanitizing data = Remove any illegal character from the data.
ex.: filter_list(), filter_var();
https://www.w3schools.com/php/php_filter.asp