mrgrammar wrote:I am working on a login system. I could just secure a directory by using a .htaccess file. However, I'm considering other options.
.htaccess ia an Apache-specific configuration option and does not constitute an authentication mechanism.
I'll assume that by ".htaccess", you mean "HTTP Authentication", which is entirely unrelated to .htaccess, except that the .htaccess mechanism is sometimes used to configure HTTP Authentication.
1. Is .htaccess actually secure or can it be hacked?
.htaccess has no inherent vulnerabilities that I'm aware of. Of course all the normal caveats apply.
HTTP basic authentication sends all credentials in the clear (unless you're using HTTPS) where they can be intercepted and compromised by someone who can tap the wire.
2. How secure is the method of using the SESSION as described above?
Provided it's a correct implementation, equally secure. Make sure you follow all the guidelines in the PHP session documentation for maximum security, i.e. ALWAYS enable session.use_only_cookies
You need to be sure that your implementation is correct and takes all security precautions (i.e. isn't vulnerable to attacks ITSELF such as SQL injection)
3. What is your suggestion for securing a directory?
That question makes no logical sense. Directories are not things which "need to be secured" in a web sense, as there is no mechanism to retrieve a directory via HTTP.
Mark