a tutti.
Premetto che ho realizzato un'area di login e iscrizione utenti attraverso Dreamweaver Mx 2004. Sì lo so che è una parolaccia quiperò per me che son profano è stato una mezza salvezza.
Il problema è che le sessioni durano troppo poco e spesso agli utenti scadono sul piu bello
Ho provato anche con
$expireTime = 60*50;
session_set_cookie_params($expireTime);
ma non c'è stato nulla da fare .. dopo 20min circa la sessione scade lo stesso!
Allora mi son detto dall'alto della mia ignoranza: "Se voglio che la Sessione duri anche diversi giorni ...Devo per forza passare ai cookie!"
Continuando ad utilizzare tale script .. è possibile fargli creare pure un cookie e farglielo leggere poi nelle altre pagine?
VALIDAZIONE LOGIN:
CODICE PAGINA RISERVATAcodice:<?php $expireTime = 60*50; // La sessione dura 50 Minuti session_set_cookie_params($expireTime); // *** Validate request to login to this site. session_start(); $loginFormAction = $_SERVER['PHP_SELF']; if (isset($accesscheck)) { $GLOBALS['PrevUrl'] = $accesscheck; session_register('PrevUrl'); } if (isset($_POST['nick'])) { $loginUsername=$_POST['nick']; $password=$_POST['password']; $MM_fldUserAuthorization = "/profilo.php"; $MM_redirectLoginSuccess = "/profilo.php"; $MM_redirectLoginFailed = "/login/fallito.php"; $MM_redirecttoReferrer = true; mysql_select_db($database_giochi, $giochi); $LoginRS__query=sprintf("SELECT nick, password FROM $table WHERE nick='%s' AND password='%s' AND status='a'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $giochi) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; //register the session variables session_register("MM_Username"); session_register("MM_UserGroup"); if (isset($_SESSION['PrevUrl']) && true) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?>
codice:<?php session_start(); $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "/login/registrazione.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?>
Ringrazio anticipatamente chiunque sappia indicarmi la strada migliore per le mie basse competenze
Saluti

a tutti.
però per me che son profano è stato una mezza salvezza.

Rispondi quotando