How do I use PHP to password-protect my directory files?

A

Anonymous

Guest
Do a search in the manual for HTTP authentication. It's chapter 18 I think. It'll describe how to use the Apache module for a password box. Simply modify the script for your own purposes and insert it in every page you want to protect
 
It's simple:
Your link for download must go on another PHP page, where you check cookies - if($variable=="value"){your page with real links to download}
else{include("login.htm");}

Sincerely,
Sergey Booyny
AlarIT programmer
http://www.AlarIT.com
 
Serg4444 said:
It's simple:
Your link for download must go on another PHP page, where you check cookies - if($variable=="value"){your page with real links to download}
else{include("login.htm");}
But someone could copy those links and then send it to someone else (who has no acces) and he can then download those files, as PyRoMaTrX allready mentioned in his post.

Greetz Daan
 
Cogen said:
How about starting a session and setting some kind of login session variable when the user logs in correctly. On all pages that require passwords, check to see if the session variable is set. If it's not, direct them to the loggin page. I think this is similar to Serg4444's method, however I don't see why it couldn't work if you use session variables.
See the first post in this topic.
The problem is/was to prevent users form downloading files (non php-files) wich they don't have acces to.

Cogen's method will work when you want to prevent acces to certain pages, I use the method on my site!
It only doesn't work for other files.

Greetz Daan
 
Back
Top