We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19487
    • 4 Posts
    Is there a way to protect files in a specified directory so that only people who are logged on have access to it?

    I’m not looking to hide the path to the file, but to actually limit it’s contents to only people who have logged into the site. This way if somebody were to actually have the direct path to the file, they would not be able to download it. I’m also not looking to use .htaccess to password protect the directory and then supply the information to access to members. Unless there is a way to do what I want with it, but I do not know of a way.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Two options would be to have the files outside of the web root, so only your download snippet would access them, or to store them as BLOBs in the database.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 28120
        • 380 Posts
        I also need to find a solution to this.

        On other sites (not Modx) I typically use an .htaccess file to validate a cookie and protect a folder e.g.

        RewriteCond %{HTTP_COOKIE} !(myCookieName=yes)
        RewriteRule ^(.*) http://www.mydomain.com/login.html [L]

        I’m planning to edit the ConfirmRegister (Login package) snippet to write the cookie.

        Is this a reasonable plan or rubbish? The documents to be protected aren’t hyper senstive; just want users to register first to gain access.