function GenerateCode()
{
// reset code
$this->sCode = '';
// loop through and generate the code letter by letter
for ($i = 0; $i < $this->iNumChars; $i++) {
if (count($this->aCharSet) > 0) {
// select random character and add to code string
$this->sCode .= $this->aCharSet[array_rand($this->aCharSet)];
} else {
// select random character and add to code string
$this->sCode .= chr(rand(65, 90));
}
}
// save code in session variable
if ($this->bCaseInsensitive) {
$_SESSION[CAPTCHA_SESSION_ID] = strtoupper($this->sCode);
} else {
$_SESSION[CAPTCHA_SESSION_ID] = $this->sCode;
}
}