![]() |
![]() |
|
| Condividi questo contenuto nei Social Network: |
|
Tweet |
|
|
|
Ti stiamo aspettando: Registrati subito e gratis. Entra a far parte di una delle comunità più attive in Italia. Se hai dimenticato i tuoi dati li puoi recuperare subito. |
||||
|
|||||||||
|
|
LinkBack | Strumenti di discussione |
|
|
#1 (permalink) |
|
User
Data di registrazione: Feb 2011
Ubicazione: Bari
Messaggi: 10
|
set-cookie
ciao a tutti,
ho creato questa area di login funzionante con la pagina di registrazione ed ovviamente mysql. il problema è che vorrei trovare il tag cookie per tener loggato un utente, ad esempio per...........una settimana. qualcuno mi puo aiutare? grazie. questa è la pagina di login: <form id="form1" name="login" method="POST" action="index.php"> <fieldset> <legend><strong>Login</strong></legend> <p> <label for="username"><strong>Username</strong></label> <input type="text" name="username" id="username" /> <label for="password"><strong><br /> <br /> Password</strong></label> <input type="password" name="password" id="password" /> </p> <p> <label for="invio"></label> <input type="submit" name="invio" id="invio" value="Accedi" /> </p> <p><a href="registrazione.php">Registrami</a><br /> </p> <?php require_once('Connections/connectdw.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "home.php"; $MM_redirectLoginFailed = "index.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_connectdw, $connectdw); $LoginRS__query=sprintf("SELECT username, password FROM utenti WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $connectdw) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();} //immagazzinano le informazioni dell'utente in un array $var_session["username"]=$row["username"]; $var_session["password"]=$row["password"]; //setto la durata del cookies a una settimana $time_cookie=3600*24*7; setcookie("session", $var_session["username"].'_&&_'.$var_session["password"], time()+$time_cookie); header("Location: " . $MM_redirectLoginSuccess ); } else { echo "Non hai inserito i dati corretti. Riprova."; } } ?><br /> </fieldset> </form> |
|
|
|
|
|