Can you please give me some ideas for good php login structure.
I was thinking of something like this:
Login page:
if logged in (checks if session exists) (
-
redirect to front page.
-
open session, save username, ID, rank to variables
)
else
-
show login form
-
check inputs comparing to database records
-
save username, ID, rank to session variables
-
show content.
Other pages:
if logged in (checks if session exists) (
-
open session, save username, ID, rank to variables.
-
show user information
)
else
- redirect to login page, or stay on the page if unlogged access is
allowed.
That is pretty much about it.
Depending on the complexity of your application and your needs, you can also take a look at authentification framworks, if you don’t want to re-invent the wheel.