我遇到了setcookie()的问题,它在localhost上运行正常但在服务器上运行不正常,这个问题发生在我将所有网页和数据库的Unicode更改为utf-8时。以下是我的代码片段:
if(isset($_GET['langid'])) {
$langID = $_GET['langid'];
setcookie('langid', $langID);
}
elseif (isset($_COOKIE['langid'])) {
$langID = $_COOKIE['langid'];
echo $_COOKIE['langid'];
}
else {
$langActive=mysql_query("SELECT * FROM languages WHERE id=2 AND active=2");
$langActive=mysql_fetch_array($langActive);
if (empty($langActive)){ $langID = 0;}
else{ $langID = 2; }
}