Colour picker persistence

Cookies are set with JavaScript when the colour picker is used, and then used to persist the styles on other pages. If JavaScript isn't available, the server-side colour picker would set the cookies. The following is an example of how the style element could be written into the head on the fly with PHP, but the principle is the same for all server-side languages.

<?php
if (strlen($_COOKIE["forecolour"]) == 4)
{
    $strForecolour = $_COOKIE["forecolour"];
}
else
{
    $strForecolour = "#000";
}

if (strlen($_COOKIE["backcolour"]) == 4)
{
    $strBackcolour = $_COOKIE["backcolour"];
}
else
{
    $strBackcolour = "#FFF";
}

echo "\t<style type=\"text/css\">body, legend, a{ color: $strForecolour; background: $strBackcolour;}</style>\n";
?>

Back to the colour picker.