Devilix Devilix - 6 months ago 22
PHP Question

PHP - redirect if there isn't a cookie or another cookie

I have cookie A and cookie B, and want to redirect to Google if no cookies are present, but if one of the two is present must not redirect.

I have made/try this one:

if (!isset($_COOKIE['Access']) || !isset($_COOKIE['Guest'])) {
header ("location:"); }

but without success... How can i solve it? Thanks


If you want it to redirect when NONE of your cookies are present your need the AND (&&) operator not the OR (||).

|| => OR


&& => AND


if (!isset($_COOKIE['Access']) || !isset($_COOKIE['Guest'])) {

should be

if (!isset($_COOKIE['Access']) && !isset($_COOKIE['Guest'])) {

Reading Material

Logical Operators