2
votes

I have the following code in .htaccess file that is not working in Firefox 25. It's works ok with Chrome, IE, Safari.

Header unset Cache-Control
Header append Cache-Control "no-cache, must-revalidate"
RewriteEngine on
RewriteCond %{HTTP_COOKIE} !^.*userloggedin.*$[OR]
RewriteCond %{HTTP_COOKIE} userloggedin=x
RewriteRule .* http://www.bostonneca.org/redir.php

I used the code to check if a cookie is set. If is not set, then I redirect the user to the login page. After log in, the user can access the folder.

setcookie('userloggedin', 'ok', time() + 60 * 60 * 5);

I guess it's a server issue because I cannot remove cookies with setcookie('userloggedin', '', time() - 1); To avoid this issue, on the logout I write a cookie

setcookie('userloggedin', 'x', time() + 60 * 60 * 5);

Please help!

Thanks, Adrian

1
Have you had a look into RewriteLog output and what headers go through FireBug or console ? You can handle all cookie stuff without rewrite anyways.Daniel W.
In Firebug, the cookie is set(please see the screenshots) varusoft.com/_ps/20131206-610-276kb.jpg and varusoft.com/_ps/20131206-h33-310kb.jpg Somehow, the cookies aren't visible in htaccess in combination with Firefox.varu
I don't have access to see RewriteLog ...varu

1 Answers

1
votes

Debugging help:

FireBug / Console - look into the headers if the cookie gets set and sent

RewriteLog - Find missconfiguration of the Rewrite

enable by:

RewriteLog /tmp/rewrite.log
RewriteLogLevel 3

(suggested is level 3 for debugging)

See also this question: https://serverfault.com/questions/499246/how-do-i-make-rewritecond-http-cookie-match-a-cookie-value-exactly

As an alternative, you can test the cookie with PHP in your index.php or whatever file you are loading or, you can redirect every request to redir.php and check the cookie in this file.