Skip to main content
Participant
December 5, 2008
Question

Restrict User Access to PDF

  • December 5, 2008
  • 1 reply
  • 347 views
I've taken over a site that was designed in coldfusion and I am just now learning the language.

For the most part everything seems to work fine. It is a user restricted site that requires visitors to have a username/password to gain access to the pages.

However...

There are a number of restricted documents on the site. All of these have a basic URL.

For example. A standard page would look like this:

http://mysite/index.cfm?action=displayCatPages&catID=6&n=31320119.585

But the document URL looks like this:

http://mysite/pages/reference/DOCUMENT3.pdf

This means that if I were to paste that URL in my browser I'd go directly to the pdf without being challenged for a username/password.

What can I do to protect these documents via coldfusion. Is there a way to pass the session ID to the document URL so that a user must be logged in to view it?

Any suggestions will be appreciated.
    This topic has been closed for replies.

    1 reply

    Participating Frequently
    December 5, 2008
    If you need to restrict access, never send a user a URL like:
    http://mysite/pages/reference/DOCUMENT3.pdf

    You need to send them something like:
    http://mysite/pages/getFile.cfm?file=DOCUMENT3.pdf

    Then the getFile.cfm page uses <cfheader> and <cfcontent> to push the contents of DOCUMENT3.pdf down to the user, once it's verified they have access.