How To Protect Pages Outside The Scripts Directory/Folder?

by 7 replies
9
Hi there,


I am having a problem with a php login script I downloaded from http://www.angry-frog.com. I have installed it correctly and works fine. But the problem I am having is when I am wanting to protect pages outside the folder/directory such as a sub-directory, the protected pages ain't protected.

Example:
PHP Login Script Location: http://www.mydomain.com/login/free/main.php
Wanting Pages Protected: http://www.mydomain.com/login/free/members/free.php
(and branched out from there)

The pages are only protected if they are in the folder where the script is located. When I place my protected pages within this directory it works fine, users who ain't logged in will get redirected to a page I have promoted. But I have got over 8000 web pages to protect within a sub-directory (see Wanting Pages Protected example URL above).

If I was to move them to this directory http://www.mydomain.com/login/free/... where the login script is located and where the protected pages work fine, this would not smart to put that many files in one directory/folder, if you know what I mean. This would be great if anyone knows how to fix this issue I am having or is familiar with this script produced by angry-frog.com (or even check the free script for your self there to know more about it).



Thanks kindly,
Daniel
#programming #directory or folder #login script #pages #protect #scripts
  • Daniel, it sounds like you do not have the paths correct when you are protecting different pages in different directories.
    This part: include ("include/session.php"); which needs to be included before the first html tag will not work for every page. No matter where the page is, it must reflect the correct path back to the location of the session.php
    That snippet just assumes you have everything in the same directory.
    I suspect this is the problem.
    So, depending on where the page is, it could look like this: include ("../include/session.php");
    • [ 1 ] Thanks
    • [1] reply
    • Hi there David V, and thank you for your quick response and interest.

      I thought that was the problem but I'm not to sure now, this is what is at the tops of all my protected pages:

      <?php
      include("include/session.php");
      if(!$session->logged_in){ header("Location: ./main.php"); } else {
      ?> //closing php tag
      Welcome
      <? echo $session->username; ?>


      As this seems to only work on pages within the directory the login script is located. Does this seem right to you?

      Thanks kindly,
      Daniel
      • [1] reply
  • Your welcome.