简体   繁体   中英

Dedicated login.php page vs index.php checking for login data

Okay, so I'm not 100% sure what the best way to implement this is. I want to create my own little webapp that requires a login to work. I know how to authenticate, that's not the problem.

Either my index page redirects to a login.php page and allows you to log in then redirects you back to index or the index page detects that you're not logged in and instead of redirecting you, takes it upon itself to print a login form instead of the main content. Not sure if that's clear.

What are the advantages/disadvantages of each.

Thanks in advance!

(I'm thinking of using OpenID but forget about that for now, I'm just curious about what the best way to implement a login system from scratch is, with a separate page or everything in the index)

I prefer to have the login form on the front page, it's one less step for your frequent users to take to use your app.

However, it is also beneficial to have a separate, clutter-free login page for when incorrect login credentials are provided. That way, your users can easily identify what went wrong and not have all the distractions commonly associated to webapp front pages. IE error messages should be very obvious and don't have to take away from what's going on over on the front page. They can have their own space on a separate login page.

Check out facebook for example: they have a pretty good implementation of what I am describing.

Does the index page have to be behind a login-wall? Because, if so, either way you're going to end up hiding it from google, et al.

Generally speaking, though, I think it's much cleaner to have the login page at a separate URL. If for no other reason than viewing your server log / analytics and being able to determine how many people viewd the home page vs. how many viewed the login form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM