Reputation: 323
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: https://www.google.com"); }
but without success... How can i solve it? Thanks
Upvotes: 0
Views: 195
Reputation: 14540
If you want it to redirect when NONE of your cookies are present, then you need the AND (&&
) operator not the OR (||
).
|| => OR
and
&& => AND
therefore
if (!isset($_COOKIE['Access']) || !isset($_COOKIE['Guest'])) {
should be
if (!isset($_COOKIE['Access']) && !isset($_COOKIE['Guest'])) {
Reading Material
Upvotes: 4