Search code examples
phpcodeignitersetcookie

why setcookie doesnt work in live website but it works in localhost?


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


Solution

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