How to create a login sessions with php

winatte -  
JooS Messages postés 2705 Statut Membre -
hello,

I've search before about it but nothing is clear i was more confused, it's ok if there is some mysql ?? any volunteer
A voir également:

1 réponse

JooS Messages postés 2705 Statut Membre 228
 
Hi,

login sessions ?! do you mean login script ?

Sessions are just a global variables that have a larger lifetime than normal variables (5 -> 30min, depending on the server configuration), nothing directly related to MySQL.

So let say you have a form that contains two text fields (username and password), after submitting the form, you have to :

1 - Check the fields content, if it's correct (not empty ... etc) ...
2 - Make a SELECT SQL query including the fields content, to check if the username and password exist in the database, if they do and match ...
3 - Create a user session to prove that the user have (already) been connected, so that you can show/hide/allow/deny the current user to do some actions.

You can for example put in the session the user id and rank (that have been recovered from the last query).
0