How to create a login sessions with php

Fermé
winatte - 1 juil. 2013 à 20:01
JooS Messages postés 2465 Date d'inscription mardi 22 janvier 2008 Statut Membre Dernière intervention 8 juin 2016 - 2 juil. 2013 à 18:20
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

1 réponse

JooS Messages postés 2465 Date d'inscription mardi 22 janvier 2008 Statut Membre Dernière intervention 8 juin 2016 228
2 juil. 2013 à 18:20
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