Bump the language cookie expiry for visits during the expiry period
authorPaul Wise <pabs@debian.org>
Sun, 25 Aug 2019 03:48:59 +0000 (11:48 +0800)
committerPaul Wise <pabs@debian.org>
Sun, 25 Aug 2019 03:48:59 +0000 (11:48 +0800)
This ensures that if the user continues to visit the website then
they don't have to manually set the cookie again until they
stop visiting the website for more than the expiry period.

modules/roles/templates/apache-www.debian.org.erb

index 2253aa7..e1759db 100644 (file)
    # The GDPR does not apply and to satisfy the EU cookie law we can include
    # some explanatory text around the form that sets the cookie.
    # The use of POST requests will ensure each cookie is only set explictly.
+   # When a cookie is set by the user, update it on every visit so it doesn't
+   # expire unless the user stops visiting the website for the cookie duration.
    # Since Apache mod_rewrite cannot inspect POST data, we use URLs instead.
    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} ^POST$
    RewriteRule /intro/cn/setlang/([a-z]{2}(?:-[a-z]{2})?)/(.*) /$2 [last,redirect,cookie=lang:$1:%{HTTP_HOST}:40320:/:secure:]
    RewriteCond %{REQUEST_METHOD} ^POST$
    RewriteRule /intro/cn/unsetlang/(.*) /$1 [last,redirect,cookie=lang:invalid:%{HTTP_HOST}:-1:/:secure:]
+   RewriteCond %{HTTP_COOKIE} /^lang=([a-z]{2}(?:-[a-z]{2})?)$/
+   RewriteRule . - [cookie=lang:%1:%{HTTP_HOST}:40320:/:secure:]
    SetEnvIf Cookie "lang=(.+)" prefer-language=$1
    Header append Vary cookie