This is my code now.
<?php
if ($_POST['change']){
$thevar = $_POST['change'];
$_SESSION['bcg'] = $thevar;
}
if(!empty($_SESSION['thecolor']))
{
$thecolor = $_SESSION['thecolor'];
}
else
{
$num = rand(0,9);
if ($num == 0)
$thecolor = "0DEBDF"; // CYAN
if ($num == 1)
$thecolor = "AE00FF"; // PURPLE
if ($num == 2)
$thecolor = "FFDC01"; // YELLOW
if ($num == 3)
$thecolor = "FF6D2D"; // PEACH
if ($num == 4)
$thecolor = "20ff7f"; // LIGHTER-GREEN
if ($num == 5)
$thecolor = "00E612"; // GREEN
if ($num == 6)
$thecolor = "E6005D"; // PINK
if ($num == 7)
$thecolor = "E600CF"; // PINK-PURPLE
if ($num ==
$thecolor = "e2ff20"; // LIME
if ($num == 9)
$thecolor = "8868ff"; // LAVENDER
// send a cookie that never expires
setcookie("thecolor",$thecolor, time()+604800);
}
?>
However, I'm now receiving this error.
Warning: Cannot modify header information - headers already sent by (output started at /home/ibran/public_html/wp-content/themes/iBran 5/header.php:9) in /home/ibran/public_html/color-change/stat.php on line 36