• Resolved tripledm

    (@tripledm)


    Hello, we have a weird installation with some custom login parts and Learndash. The problem is when a user is logging in then another user’s details is showing so a cache issue.

    Do Not Cache Cookies, as the user session cookies are unique is it possible to only enter part of the cookie as it might be session_cookie_11122 as example where the number is dynamic so just need to know if start or partial is good enough for it to pick it up and exclude that cookie from being cached.

    Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Cache plugin function to do not cache cookies expects the cookie name and not its value. You want a cookie not to be cached if he has a value like xyz****. This cannot be done with plugin functions, so you must it do “hardcore” with .htaccess rewrite rules.

    If the cookie prefix value is “session_cookie_” you can define a wildcard suffix like:

    RewriteCond %{HTTP_COOKIE} session_cookie_=[0-9]+ [NC]
    RewriteRule .* - [E=Cache-Control:no-cache]

    I hope that is what you asked for?

    Thread Starter tripledm

    (@tripledm)

    that helps a lot thank you I am going to give that a try

    Thread Starter tripledm

    (@tripledm)

    Sorry just to ask, if I have multiples ok to do with one rewrite rule eg.

    RewriteCond %{HTTP_COOKIE} session_cookie_=[0-9]+ [NC]
    RewriteCond %{HTTP_COOKIE} session_cookie2_=[0-9]+ [NC]
    RewriteCond %{HTTP_COOKIE} session_cookie3_=[0-9]+ [NC]
    RewriteRule .* - [E=Cache-Control:no-cache]
    
    • This reply was modified 2 years, 3 months ago by tripledm.

    Change it to:

    RewriteCond %{HTTP_COOKIE} session_cookie_=[0-9]+ [NC] [OR]
    RewriteCond %{HTTP_COOKIE} session_cookie2_=[0-9]+ [NC] [OR]
    RewriteCond %{HTTP_COOKIE} session_cookie3_=[0-9]+ [NC]
    RewriteRule .* – [E=Cache-Control:no-cache]

    Thread Starter tripledm

    (@tripledm)

    thank you!

    @tripledm

    There was a typo in my code, so you have to correct it, sorry.

    RewriteCond %{HTTP_COOKIE} session_cookie_[0-9]+ [NC] [OR]
    RewriteCond %{HTTP_COOKIE} session_cookie2_[0-9]+ [NC] [OR]
    RewriteCond %{HTTP_COOKIE} session_cookie3_[0-9]+ [NC]
    RewriteRule .* – [E=Cache-Control:no-cache]
    Plugin Support qtwrk

    (@qtwrk)

    maybe change [NC] [OR] to [NC,OR] ?

    I never seen a rule with two [XX] though , not sure if is supported or not …

    • This reply was modified 2 years, 2 months ago by qtwrk.

    @qtwrk

    Why shouldn’t it work? There is nothing wrong!

    https://www.htaccesscheck.com/

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Do Not Cache Cookies from cache’ is closed to new replies.