Skip to main content
Inspiring
June 12, 2014
Question

Password Protect all .cfm files in a directory?

  • June 12, 2014
  • 1 reply
  • 1385 views

Greetings

Can anyone share the code one one put within the application.cfm to password-protect all the files in that directory?

The UN & PW are stored in a DB - of course I could create a session_ID and protect each page individually, which I have been doing for years, but in this case, the pages are being loaded using a half-*ss CMS and the users, other than saving files as .cfm, will not be responsible to leave the code on each page.

In the DB, the user name is subscriber_email, the password is subscriber_password.

Thanks for any help.

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
June 16, 2014

It is unclear what you wish to password-protect against. Accessing the directory? Writing a file into it? Opening a file in it? Requesting a CFM file in it by means of the browser?

Inspiring
June 16, 2014

Thank you for your reply.

The administrator will be uploading files to the directory via FTP. His access is controlled at that point.

Users need to sign up via a form and pay a fee. Once they are approved, they should be able to access all the CFM files in that directory via their browser.

Again, I have accomplished this for years by simply creating a session ID, and,  at successful login protected every page individually:

<CFIF NOT IsDefined("Session.user_id")>

<cflocation url="login.cfm" addtoken="No">

<cfelse>

webpage

</cfelse>

but never had admins in control of uploading web pages that are unfortunately poorly coded and could never be responsible to add the above code to each page.

What is your advice?

Thanks again

Norman

BKBK
Community Expert
Community Expert
June 16, 2014

You have to add the above code to just one page, namely, Application.cfm. In other words, your approach remains valid.