Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13

Discussione: sessioni

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929

    sessioni

    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


  2. #2
    Utente di HTML.it L'avatar di gianiaz
    Registrato dal
    May 2001
    Messaggi
    8,027
    ti mostra qualche errore?

    quando fai riferimento a una variabile di sessione punti all'array $_SESSION vero?


  3. #3
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    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;
    }
    ?>

  4. #4
    Utente di HTML.it L'avatar di gianiaz
    Registrato dal
    May 2001
    Messaggi
    8,027
    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:

    codice:
    function pre($array) {
     if(empty($array)) {
       echo "array inesistente";
     }
    echo "<pre>";
    print_r($array);
    echo "</pre>";
    }
    ciao

  5. #5
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    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);
    
    ?>

  6. #6
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    ops scusa mi viene fuori solo in locale

    codice:
    Array
    (
        [MM_Username] => GUEST
        [MM_UserGroup] => 
    )
    e la user è giusta

    :master:

  7. #7
    Utente di HTML.it L'avatar di gianiaz
    Registrato dal
    May 2001
    Messaggi
    8,027
    prova a postare la pagina che registra l'utente in sessione.

    ciao

  8. #8
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    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 );
      }
    }
    ?>
    :master:

  9. #9
    Utente di HTML.it L'avatar di gianiaz
    Registrato dal
    May 2001
    Messaggi
    8,027
    Sostituisci tutti i session_register.

    ad esempio da cosi:
    codice:
    if (isset($accesscheck)) {
      $GLOBALS['PrevUrl'] = $accesscheck;
      session_register('PrevUrl');
    }
    a cosi

    codice:
    if (isset($accesscheck)) {
      $_SESSION['PrevUrl'] = $accesscheck;
    }

  10. #10
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    ho sostituito alla pagina dove registro le sessioni cosi
    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 );
      }
    }
    ?>
    mentre questo è il codice della pagina che mi respinge (a cui non riesco ad accedere)
    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);
    
    ?>
    ma continua e negarmi l'accesso (solo su aruba mentre in locale funziona)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.