I want to check a cookie with name "subscription" and there are 3 cookies with this name but has different paths as follows path 1 is / path 2 is /customer/checkout/ path 3 is /customer/register/
now if i want to apply an if condition if subscription is set then the condition works only for path 1.How do I make it work for all three paths???
I don't think you can reliably check the path of a cookie in PHP (or any serverside language for that matter) as most or at least some browsers don't send the path for the cookie. They only send key-value pairs.
If reliability/cross browser support isn't a must, you could check if the path of the cookies is send with the request headers. Use a method like
<?php
foreach (getallheaders() as $name => $value) {
echo "$name: $value\n";
}
?>
http://www.php.net/manual/en/function.getallheaders.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With