Back to Fred Mac Donald's Blog

mod_expire and cookies not working

mod_expire and cookies not working

Problem with not being able to refresh some cookies while having mod_expire set in your htaccess file?

I have been using the script below in my htaccess file for some time now with great success until recently.

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"

I am not sure what changed where but for some reason I could not update a cookie managing the currency setting on my e-commerce website.

I was able to switch to each currency only once. From there it was stuck on the last currency and even the redirection after the cookie update was stuck on the last page I successfully updated the currency cookie from.

After a lot of frustration and digging, I found these two lines to be the cause of it all.

##ExpiresByType text/html "access 1 month" ## messes with cookies
##ExpiresDefault "access 1 month" ## messes with cookies

Commented them out and everything started working as expected. I am not sure if it is a setting in my chrome browser that causes the conflict.

If any XMS Systems users have this problem, please contact us via the normal channels and we will get your htaccess file updated.

Written by:  - 6 Feb, 2018  
comments powered by Disqus