0

I have a captcha script on

captcha link

it uses following code:

include 'kcaptcha/kcaptcha.php';
$path = "/";
//this line will produce captcha image
$captcha = new KCAPTCHA();
//writing the cookie so that we can check on next page



//captcha value save as md5 encryption so that when validating is should make md5 mask to captcha form input
setcookie("captcha", md5($captcha->getKeyString()), time()+1000, $path);

This code works on localhost but doesnt work on my live website. What is wrong?

Thank You

danny
  • 465
  • 3
  • 8
  • 18
  • Outputting the image data, *then* sending the cookie, are we? Use a hexeditor and peek at the trailing garbage (you've got two pretty html error messages) after the image data. – mario Apr 05 '12 at 00:58
  • possible duplicate of [Headers already sent by PHP](http://stackoverflow.com/questions/8028957/headers-already-sent-by-php) – mario Apr 05 '12 at 00:59
  • If that was the case, it wouldn't work locally. I'm guessing he's outputting the image later. Where is the script installed on your server? If it's /scripts/myscript.php or something then the $path = "/" wouldn't work. You could also try setting the domain value (the next parameter) to ".mydomain.com". – Andrew Kandels Apr 05 '12 at 00:59

1 Answers1

1

Is the domain entered properly in $config['cookie_domain'] in config/config.php?

Yan Berk
  • 14,328
  • 9
  • 55
  • 52