<?php
session_start();

// Must set ONLY ONE content type
// header("Content-Type: text/plain");

// Generate a random 4-digit code
$captcha_code = substr(str_shuffle("1234567890"), 0, 4);

// Save in cookie (10 minutes)
setcookie('captcha_code', $captcha_code, time() + 600, "/");

// Save in session
$_SESSION['captcha'] = $captcha_code;


// Output the captcha as text
echo $captcha_code;
exit;
