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

Go To StackoverFlow.com

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

2012-04-05 00:51
by danny
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 2012-04-05 00:58
possible duplicate of Headers already sent by PHPmario 2012-04-05 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 2012-04-05 00:59


1

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

2012-04-12 13:43
by Yan Berk
Ads