Skip to main content
Inspiring
August 24, 2009
Question

Secure a folder with sessions - PHP/MySQL

  • August 24, 2009
  • 1 reply
  • 588 views

I have a member site that I hav erecently developed a download library for. All the downloads (Word docs or PDFs) are stored in one directory and the user must be logged in using a session based system to gain access to the download page (in the directiry above) which contains all the links to the documents.

So non members can't access the downloads page but I'm guesssing that pretty soon each of the PDFs and Word docs will be picked up by google  and non-members will be able to open or download them directly.

Is there a way that I can secure access to the contents of the download folder using sessions?

Or if not any other solution?

Cheers

Dave

This topic is closed to new replies. Start a new post to keep the conversation going.

1 reply

Participating Frequently
August 24, 2009

The simple way is to put all of the docs in a folder that you secure using web server security. Most hosting plans these days make this option available from the host control panel. The problem with this is that it is a different security layer than the one you are currently using, and integrating the two , while possible, might be challenging.So you might instead just put all of the documents, including html, into a secured folder and use that security method instead.

Another method to consider is putting all of the sensitive docs in a directory above the site root, and then use server side scripting on a secured page to stream the files. It's relatively simple and you can use a script like this one:

http://www.computerhope.com/issues/ch001113.htm