Jump to content

"Secure" PHP Login Script?


notepad

Recommended Posts

Hi,

 

I am thinking of integrating this PHP login script: http://www.phpeasystep.com/phptu/6.html. I am still learning PHP, so I am not really sure if this script is secure. I will do a couple of things to it, like md5 the passwords and use preg_replace to strip out non-alphanumeric characters. But I don't really know how 'secure' the sessions are. I know there are certain ways to get around those if you don't code your script right... So I was hoping a could get some of your thoughts on the code.

 

The protection for the pages is this:

 

<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>

 

One other thing is that I only need one user. So, should I change the SQL query to this?:

 

CREATE TABLE `members` (
`id` int(4) NOT NULL,
`username` varchar(65) NOT NULL default '',
`password` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM ;

 

Thanks,

 

Brandon

Link to comment
Share on other sites

do research and read about session sniffing and session security

 

as long as your not storing passwords inside sessions you should be fine, some people dont use session all together and simulate sessions with table in a db, but thats another mess all together

 

as far as md5 and proper password encrypting, do research on salting md5 passwords, and read comments in the php.net manual

 

think about "what makes a login system secure"

once you can answer that question, then you can find out things and do research on the insecure aspects of a user authentication system, the ones I listed were just a couple i thought of when it comes to user authentication security

Link to comment
Share on other sites

Hey dsaba, thanks for your tips. I will do some research on the things you mentioned. You also posed a very good question: "what makes a login system secure". And, to be honest, I can't answer it -- Yet. But I will be doing a lot of research, so I can answer it. =)

Link to comment
Share on other sites

  • 3 weeks later...

From what I can tell, it looks like anyone could just add a cookie to their browser with the right username and get past your script. If you have an account called admin, guest, etc than it would probably pretty easy to get around. It's usually safest if you have php do md5 encryption, store the encrypted password in a database, then check the cookie against the encrypted password. If you want to get real dirty you can have it use the time added to the end of the encrypted password to really throw off someones cracking tool.

 

Unless you have a site with important information like credit card numbers etc, then just basic md5 encryption is probably all you need. Just make sure you are not passing the "plain text" version of the password into the cookie or you could also help hackers get into any other website that person goes to. Many people use the same password for all their sites like banks etc.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.