How to protect other files in Login folder etc
In the past I have always used .htaccess to protect folders so this is my first attempt at an actual login script & I have some questions. So far I have done the Login and the Lost Password parts, and they work great, but are probably not as secure as they could be.
1. .htaccess protects all files in the folder but login does not. After reading posts from other people writing login scripts, I get the impression that you have to put require_once('login.php') (or something) at the top of each file in the folder and use sessions somehow. I have googled sessions and I still don't quite get it. Can someone please explain sessions from scratch?
2. Are sessions necessary for login scripts? They seem to be for logging users out after a set length of time, or remembering info from their last session. Can you control what values are stored in the session info? Are cookies files that store the session info?
3. I understand == but what does === mean?
4. Is this a good function to use to prevent SQL injection?
Code:
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
5. I know in php.ini that magic_quotes_gpc = On, so what does this mean...
Code:
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
and what does it accomplish security-wise? Do people use slashes in SQL injection?
6. Does this remove blanks at each end of a string? Anything else?
$str = @trim($str);
7. Is it necessary to md5 encrypt the passwords in the database? If encrypted, how do you send people forgotten passwords? If they are decryptable, couldn't anyone do it? So what is the point?
Thanks for any help. e :)