Forum Moderators: coopster
I'm trying to create a secure login/register system for my site.
Could some of the experts give me a guide on how to do it, taken in mind the security issues i should be aware of.
I've done a little research myself, and I want to do it myself from scratch.
I'm not looking for a tutorial, but only a guide (in words) on the proper steps to take in creating such a system.
The system has to contain a login page, a register page, an e-mail confirmation, and a session cookie.
The other features, such as "remember me", "forgotten password", etc, I'll figure out by myself.
Thank You very much, and I hope I'm not asking too much.
[edited by: coopster at 8:21 pm (utc) on Dec. 16, 2008]
[edit reason] no personal urls please TOS [webmasterworld.com] [/edit]
I kind of figured out how to make a confirmation mail.
I generate a random number, put it in a get variable inside a link in the mail, retrieve it, compare it etc...
(Is this ok?)
What I'm not actually sure of is what is the purpose of a md5 encrypted password stored in a database?
Why not just store as plain text?
Keep shooting me posts and I can walk you through this on as basic of a step by step as you need.
Let's say i store the random number for the confirmation (or fpass) in a separate table only for those numbers.
(Don't know if it's a good approach?)
How do I set the automatic deletion of the number if the user doesn't click the link (in 24 hours, for example)?
Thanks for Your help andrewsmd.
when they enter their e-mail address in the forgot password form remove them from your users and enter their information into the forgot password table along with the unix time of when they submitted
a unix time stamp is the number in seconds after some year (like 1970 somthing) anyways 24 hours would be 60 * 60 * 24 (seconds minutes hours). so when the user clicks on their random link then you could store that link into a session variable and redirect them to a password reset form.
once they reset their password you can select from that table where the link in the session variable matches the link in the table and it is not less than the current unix time minus 60 * 60 *24 that would be minus one day. If it's greater than that then they did not click it in time. Also I would schedule a script to run every hour to go through that table and take anything a day old and re insert it back into your user table. Let me know if you need more specifics
I know there is mysql syntax to look for stuff based on time but I don't know it at all. Like I said I like to use as much PHP as possible
MD5 encryption by itself is not as safe as it should be anymore, and therefore it is recommended to also add a random seed to the password you are encrypting. For instance, let's say this is what you are putting into the database:
md5($password.'some_seed');
This ensures that even if the password is a common word that a reverse look-up of the encrypted string cannot be found. Of course, your seed has to be kept the same throughout otherwise you will not be able to compare the password when entered.
//the current time
$timeStamp = date("H,i,s,m,d,Y");
//the current time in unix
$time = mktime($timeStamp);
//change this to the number of days before
//the current day that
//you want to keep things.
$numOfDays = 1;
$timePlusOneDay = $time + 60 *60 * 60 * $numOfDays;
//this will remove anything older than a day
//just add * # of days to the previous variable
//to add more days i.e. 10 days would be
//$time + 60 * 60 * 60 * 24 * 10
$query = ("delete from table where columnUnixTime < {$timePlusOneDay};";
connect with that query and tada! everything older than one day is gone.
I have posted another topic related to this.
>>that would mean i would have to regularly maintain the database manually<<
If You are referring to this above, I am looking for something to do the lookup and erase unnecessary table rows by itself.
That means that it has to be triggered by itself, not by a user action.
p.s.
>>connect with that query and tada<<
I'm trying to find something (possibly a cron job?) to do that by itself, in a given time interval.
XP IE user
start iexplore www.someaddress.com
ping -n 60 127.0.0.1
taskkill /f /im iexplore.exe
XP Firefox user
start firefox www.someaddress.com
ping -n 60 127.0.0.1
taskkill /f /im firefox.exe
Vist IE user
XP IE user
start iexplore.exe www.someaddress.com
ping -n 60 127.0.0.1
taskkill /f /im iexplore.exe
Vista Firefox user
XP IE user
start firefox.exe www.someaddress.com
ping -n 60 127.0.0.1
taskkill /f /im firefox.exe
save that in notepad as wateveryouwant.bat make sure it has a .bat extension (the icon will look like two little gears).
www.someaddress.com is the address of the php file you created that cleans out your mysql table
Then go control panel scheduled tasks and schedule that file to run as often as you want. the ping -n 60 127.0.0.1 is just to pause to let the script run change the 60 to higher or lower to make it wait longer or less.