Subscribe RSS

Tag-Archive for "security"

Cookies with apache Feb 02

 

The moment the left join becomes clear

I recently had the need to setup part of a website so that the user needed to agree to terms before accessing. I was not happy about having to make the pages dynamic or use javascript. So instead, this rather elegant apache solution does the job.

 

This example is based on a three page system, obviously an be made far more flexible than this.

The page “mustagreetoview.html” can only be viewed if the user has agreed to the terms – indicated by the presence of the ‘hasgreed’ cookie. If the cookie ‘hasagreed’ is not set the user is directed to the terms page “pleaseagree.html”. This simply explains to the user that they need to agree to the terms before continuing. The agree link takes the user to “useragress.html”. When this page is requested the “hasagreed” cookie is set by apache.


RewriteRule ^.*useragrees.html$ - [co=hasagreed:YES:.%{SERVER_NAME}]

RewriteCond %{HTTP_COOKIE} !^.*hasagreed.*$ [NC]
RewriteRule ^.*mustagreetoview.html$ /pleaseagree.html [R]

Category: Apache  | Tags: , ,  | Leave a Comment