ciao a tutti,
ho un problema, ho fatto un'area riservata con le sessioni in locale funziona tutto benissimo, mentre quando pubblico su aruba le sessioni non funzionano più, qualcuno sa dirmi da cosa può dipendere?
Grazie mille
![]()
ciao a tutti,
ho un problema, ho fatto un'area riservata con le sessioni in locale funziona tutto benissimo, mentre quando pubblico su aruba le sessioni non funzionano più, qualcuno sa dirmi da cosa può dipendere?
Grazie mille
![]()
ti mostra qualche errore?
quando fai riferimento a una variabile di sessione punti all'array $_SESSION vero?
![]()
codice:<?php session_start(); $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { $isValid = False; if (!empty($UserName)) { $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "../fallito.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; } ?>![]()
come al solito per debug consiglio di stampare a video il contenuto degli array, stessa cosa vale per $_SESSION, cosi vedi se è vuoto o pieno e ti regoli di conseguenza.
Io metto sempre questa funzione in un file che includo, mi risulta molto comoda:
ciaocodice:function pre($array) { if(empty($array)) { echo "array inesistente"; } echo "<pre>"; print_r($array); echo "</pre>"; }
ho fatto cosi :master: niente![]()
codice:<?php session_start(); $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { $isValid = False; if (!empty($UserName)) { $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "../fallito.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; } function pre($array) { if(empty($array)) { echo "array inesistente"; } echo "<pre>"; print_r($array); echo "</pre>"; } pre($_SESSION); ?>![]()
ops scusa mi viene fuori solo in locale
e la user è giustacodice:Array ( [MM_Username] => GUEST [MM_UserGroup] => )
:master:
prova a postare la pagina che registra l'utente in sessione.
ciao
:master:codice:<?php session_start(); $loginFormAction = $_SERVER['PHP_SELF']; if (isset($accesscheck)) { $GLOBALS['PrevUrl'] = $accesscheck; session_register('PrevUrl'); } if (isset($_POST['user'])) { $loginUsername=$_POST['user']; $password=$_POST['pw']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "rivenditori/autenticato.php"; $MM_redirectLoginFailed = "rivenditori/fallito.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_conn, $conn); $LoginRS__query=sprintf("SELECT ragionesociale, partitaiva FROM clienti WHERE ragionesociale='%s' AND partitaiva='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $conn) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; session_register("MM_Username"); session_register("MM_UserGroup"); if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?>
Sostituisci tutti i session_register.
ad esempio da cosi:
a cosicodice:if (isset($accesscheck)) { $GLOBALS['PrevUrl'] = $accesscheck; session_register('PrevUrl'); }
codice:if (isset($accesscheck)) { $_SESSION['PrevUrl'] = $accesscheck; }![]()
ho sostituito alla pagina dove registro le sessioni cosi
mentre questo è il codice della pagina che mi respinge (a cui non riesco ad accedere)codice:<?php session_start(); $loginFormAction = $_SERVER['PHP_SELF']; if (isset($accesscheck)) { $_SESSION['PrevUrl'] = $accesscheck; } if (isset($_POST['user'])) { $loginUsername=$_POST['user']; $password=$_POST['pw']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "rivenditori/autenticato.php"; $MM_redirectLoginFailed = "rivenditori/fallito.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_conn, $conn); $LoginRS__query=sprintf("SELECT ragionesociale, partitaiva FROM clienti WHERE ragionesociale='%s' AND partitaiva='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $conn) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; session_register("MM_Username"); session_register("MM_UserGroup"); if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?>
ma continua e negarmi l'accessocodice:<?php session_start(); $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { $isValid = False; if (!empty($UserName)) { $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "../fallito.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; } function pre($array) { if(empty($array)) { echo "array inesistente"; } echo "<pre>"; print_r($array); echo "</pre>"; } pre($_SESSION); ?>(solo su aruba mentre in locale funziona)