In my .htaccess files:
For proper Cookies I use this, that's OK if I check whether there exists a cookie.
RewriteCond %{HTTP_COOKIE} (my\_cookie) [NC]
But when I tried to check for zero values and use these choices, it fails to match cases:
RewriteCond %{HTTP_COOKIE} ^.*my\_cookie=0.*$ [NC]
RewriteCond %{HTTP_COOKIE} my\_cookie=0 [NC]
RewriteCond %{HTTP_COOKIE} (my\_cookie=0) [NC]
When I make print_r ( $_COOKIE );
I get this:
Array
(
[analytics] => true
[CakeCookie] => Array
(
[my_cookie] => 0
[newuser] => 1
)
)
How can I check the cookie value for this case?
Im using same solution for handle language:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_COOKIE} lang=([^;]+) [NC]
RewriteRule ^(.*)$ /$1?lang=%1 [NC,L,QSA]
but I checking value in php file. I hope that it will be helpful for u ;)
After too many tryouts, this solved my issue:
RewriteCond %{HTTP_COOKIE} CakeCookie.*my\_cookie.*=0
I still don't know what would be exact pattern instead of .*
but this one works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.