Ho letto il seguente articolo: http://freephp.html.it/articoli/view...olo.asp?id=132
Tendendo presente che:
---auth.lib.php---
..
....
Codice PHP:
function auth_get_status(){
global $_CONFIG;
auth_clean_expired();
$uid = auth_get_uid();
if(is_null($uid))
return array(100, NULL);
$result = mysql_query("SELECT U.name as name, U.surname as surname, U.username as username, U.password as password
FROM ".$_CONFIG['table_sessioni']." S,".$_CONFIG['table_utenti']." U
WHERE S.user_id = U.id and S.uid = '".$uid."'");
if(mysql_num_rows($result) != 1)
return array(100, NULL);
else{
$user_data = mysql_fetch_assoc($result);
return array(99, array_merge($user_data, array('uid' => $uid)));
}
}
function auth_login($uname, $passw){
global $_CONFIG;
$result = mysql_query("
SELECT *
FROM ".$_CONFIG['table_utenti']."
WHERE username='".$uname."' and password=MD5('".$passw."') and temp = '0'"
);
if(mysql_num_rows($result) != 1){
return array(AUTH_INVALID_PARAMS, NULL);
}else{
$data = mysql_fetch_array($result);
return array(AUTH_LOGEDD_IN, $data);
}
}
..
....
L’utente registrato accede ad una pagina come questa:
----pagina2.php----
Codice PHP:
include_once("include/config.php");
include_once("include/auth.lib.php");
list($status, $user) = auth_get_status();
if($status == AUTH_LOGGED){
}
else {
}
Non sono riuscito a capire quale sia il metodo (in pagina2.php) per estrapolare dal database le info dell'utente e stamparle a video.
Potete scrivermi la query/comando da usare?
Tutto il codice è spudoratamente copiato da quell’articolo lo so, a me interessa sapere come funzionano le sessioni.