Posts: 876
Name: Matt Pealing
Location: England, north west
|
Ok I should probably start by pointing out that it's NOT secure, well not yet anyway.
At the moment, my system checks to see if the user is logged in, then it will just insert the relevant HTML file. For example, I might have two files in an includes folder:
1. default.htm
Code:
<h1>You are not logged in</h1>
2. loggedIn.htm
Code:
<h1>Welcome Back!</h1>
Then the PHP code will just include either one, depending on whether or not $_SESSION['userId'] has been set.
Then after a while I realised how insecure it is. Basically any user could just type in the location to something like 'loggedIn.htm' and see what is available to users who have logged in.
Is a better way of doing it something like this:
1.Set the file permissions to the HTML includes folder to '000' so that no-one can access it
2. Use the chmod function in PHP to temporarily allow access, do it's business then set it back to '000' before ending the script.
Would that be a secure and efficient way of doing it? Or do I need to completely re-think how I'm building PHP applications?
Last edited by pealo86; 04-25-2009 at 04:30 AM..
|