Mengatasi ERROR: Cookies are blocked due to unexpected output di WordPress

Error:

ERROR: Cookies are blocked due to unexpected output.

sebenarnya bukan karena browser memblokir cookie, tetapi karena WordPress mengirim output (teks, spasi, warning, atau error PHP) sebelum header cookie dikirim. Akibatnya WordPress gagal membuat session login.

Dari pengalaman saya menangani WordPress, sekitar 90% penyebabnya adalah salah satu dari berikut ini:

1. Plugin yang error (penyebab paling sering) ⭐⭐⭐⭐⭐

Biasanya setelah update plugin atau install plugin baru.

Cara cek

Melalui File Manager/cPanel:

wp-content/plugins/

Rename folder:

plugins

menjadi

plugins_old

Kemudian coba login lagi.

Kalau berhasil login berarti ada plugin yang bermasalah.

2. Theme error

Rename folder theme yang sedang aktif.

Misalnya

wp-content/themes/astra

menjadi

astra_old

WordPress otomatis menggunakan theme default.

3. Ada spasi sebelum <?php atau setelah ?>

Misalnya pada file

wp-config.php
functions.php

atau file plugin.

Contoh yang salah

(space)

<?php

atau

?>

(space)

Output sekecil apapun akan menyebabkan error cookie.

4. Ada Warning PHP

Contoh

Warning:
Notice:
Deprecated:
Fatal error:

yang muncul sebelum halaman login.

Ini juga membuat cookie gagal dibuat.

5. File wp-config.php rusak

Pastikan bagian paling awal file adalah

<?php

Tidak boleh ada

  • BOM UTF-8
  • spasi
  • baris kosong

di atasnya.

6. URL Website Tidak Sama

Cek database tabel

wp_options

Nilai

siteurl
home

harus sama.

Misalnya

https://tukangtamanasri.com

bukan

http://

atau

www.

yang berbeda.

7. File .htaccess rusak

Rename

.htaccess

menjadi

.htaccess_old

Lalu buat baru

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

8. Cache Server

Jika memakai

  • LiteSpeed Cache
  • WP Rocket
  • SG Optimizer
  • Cloudflare

hapus cache semuanya.

Cara mengetahui penyebab pastinya

Aktifkan debug WordPress.

Pada

wp-config.php

ubah menjadi

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Kemudian coba login.

See also  Mengatasi Error Web: PHP Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)

Lihat

wp-content/debug.log

Biasanya akan langsung terlihat plugin atau file yang error.