0
我有爲什麼setcookie不工作在現場網站,但它在localhost工作?
驗證碼腳本,它使用下面的代碼:
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);
此代碼工作在本地主機,但不工作在我的直播網站。哪裏不對?
謝謝
輸出圖像數據,然後*發送cookie,是我們嗎?使用hexeditor並查看圖像數據後面的垃圾(您有兩個漂亮的html錯誤消息)。 – mario 2012-04-05 00:58:21
[Headers already already been sent by PHP]可能的重複(http://stackoverflow.com/questions/8028957/headers-already-sent-by-php) – mario 2012-04-05 00:59:23
如果是這樣的話,它不會在本地工作。我猜他以後會輸出圖像。腳本在服務器上安裝在哪裏?如果是/scripts/myscript.php或者其他東西,那麼$ path =「/」將不起作用。您也可以嘗試將域值(下一個參數)設置爲「.mydomain.com」。 – 2012-04-05 00:59:42