davidj01 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have a perl application for registration and login. It password protects files using a redirect script. It creates a session id using a cookie after the user logs in from a web page. Every script then checks the session cookie.

I want to use it to protect a folder not just a file But I don't want to use .htaccess etc. thats is I want use only a web page for the login.

Any ideas. I have access to apache web server so perhaps I could do it from there.

Thanks/David J.

Replies are listed 'Best First'.
Re: Password Protect Directory
by choroba (Cardinal) on May 04, 2010 at 16:52 UTC
    What do you mean by "protecting a folder"? Creating an index in it, that will check the cookie? Or just forbid apache to browse folders?
      Hi,

      I want the user to log in via a web page to get access to any file under a specific folder.

      Lets call it /members

      Is there a way to get the web server to check that the user is logged in by checking a valid login cookie created by the login script then allow the user to access any web page or file under that folder.

      Thanks/David J

        You can include the checking script from all the files in the folder, or you can have just one script that checks the cookie and then does various things based on parameters (thence, the URLs will be like members/onescript.pl?show=secret instead of members/secret.pl; in such a case, do not forget to check that the value of the parameter is valid).