我有以下兩個鏈接:PHP創建和刪除cookies
<a href="index.php?showDesktop=true">Show Desktop</a>
<a href="index.php?showMobile=true">Show Mobile</a>
我想要做的就是讓這個如果單擊showDesktop查詢,然後創建一個名爲showDesktop cookie,並刪除cookie showMobile,反之亦然。到目前爲止,我嘗試了以下方法,但認爲我做錯了。任何人都可以幫助我按照建議進行工作。
if($_GET['showDesktop']) {
$_COOKIE('showDesktop', 'yes');
$_COOKIE('showMobile', null);
}
else if($_GET['showMobile']) {
$_COOKIE('showDesktop', null);
$_COOKIE('showMobile', 'yes');
}
'$ _COOKIE'不是函數刪除Cookie。 –