View Full Version : Only View Pages If Logged In

02-15-2008, 01:04 AM
I am building a backend area on a website, which needs the user needs to be logged in to access... I have been able to make it so they login and then get re-directed to the page, but the individual pages can still be accessed directly by typing them into the browser... What would I need to put at the top of these page to stop that from happening?

02-15-2008, 01:06 AM
That's what sessions are for. Once a user logs in, you assign a value to a session variable and redirect. On the private page, the first thing you do is check that session variable and if it's missing, redirect to a public page, or display an error message.

02-15-2008, 01:08 AM
Ok I'm not the greatest at php, any step by step you could tell me?

02-15-2008, 01:14 AM
Step 1 (http://www.google.com/search?hl=en&q=session+%2Bphp&btnG=Google+Search)

After you've spent a couple of hours on step 1, come ask about step 2.