Jump to content

how easy is it to password protect?


jacko_162

Recommended Posts

i have designed a cms system with my basic knowledge of .php some old .php scripts off a friend and help from this forum, the last thing on my list before i can make my site go live now is to password protect the admin backend.

 

can anyone offer any code snippets or tutorials on how i can achieve this please.

 

 

Thank you very much.

Link to comment
https://forums.phpfreaks.com/topic/84946-how-easy-is-it-to-password-protect/
Share on other sites

i do have access to sql, but i dont have a clue about sessions or cookies!?

 

if i want to log in from a number of locations am i best using sessions?! for now i only want one password and username to access the whole control panel but it would be nice to have 2 types of users 1 full control and 1 to just control products??

 

like i said anyone wanna help me with this? or links to code snippets and/or tutorials?!

Search for a PHP Authentication script, you'll find tons.

 

You'll want to use sessions after you log in to track your "Role", and you can use a Cookie if you want to store info so you don't have to log in again when you return.

 

i do have access to sql, but i dont have a clue about sessions or cookies!?

 

if i want to log in from a number of locations am i best using sessions?! for now i only want one password and username to access the whole control panel but it would be nice to have 2 types of users 1 full control and 1 to just control products??

 

like i said anyone wanna help me with this? or links to code snippets and/or tutorials?!

The best and most secure way for a novice PHP programmer is to use sessions/cookies.

 

By simply calling session_start() a session id will be assigned to the client. This will be stored in a cookie and sent back and forth between the server and the client untill the session is ended. A session can be ended using session_destroy() or by a user closing their browser/deleteing their cookies.

 

When a client logs in correctly, create a session variable called 'isAuthorised' and set it to true.

 

Every page that requires the client to be authenticated simply check whether or not isAuthorised is true or false.

 

I hope this helps

this sounds pretty easy(ish) is there anywhere i can go visit to give me an example of this code to use or a tutorial of some sort?!

 

i only need 2x users, one main admin and another to only access product pages (add, deltete, view etc..)

 

Thank you guys

 

p.s i am currently using .htaccess and i am not overly keen on this method as i know it can be worked around..

Create a class heirarchy of authentication, which you can apply to other classes, and then create a single point of entry (i.e. front controller, if you want to google it). This should alleviate some of your issues, or possibly create others if you don't have a great grip of classes.

 

Sessions are you only option really, so go down that road. .htaccess is fine, but unmaintainable...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.