Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    Cookie... please help me!

    vi prego aiutatemi!
    Non mi funzionano i cookie al mio sito in PHP!
    Vi spiego velocemente il problema:

    1) questo è il mio codice:
    codice:
    setcookie ("AUTENTICAZIONE_username", $AUTENTICAZIONE_username, $newtime, "/prova.it/");
    2) il sito è organizzato così:
    nella root principale c'è una cartella "prova.it" e dentro di quella ci sono tutti i file e le cartelle. Io eseguo il login nella cartella "prova.it/amministrazione/index.php" che viene rediretta nella cartella "prova.it/amministrazione/autenticazione/auth.php"

    credo che il mio problema sia in "/prova.it/" eppure in locale funzionava...

    please please!!

    |--- |--- |- |---
    | | | \ |
    |-- |-- | | |--
    | | | / |
    | |--- |- |---

  2. #2
    Utente bannato
    Registrato dal
    Sep 2005
    Messaggi
    905
    prova a scrivere solo
    setcookie("nome", "valore", $newtime);
    a volte la specificazione della directory è meglio tralasciarla altrimenti ci si ingarbuglia da soli.

  3. #3
    lo so che forse chiederò troppo però posto tutto il file "auth.php" se potete aiutarmi mi dareste una mano enorme

    codice:
    <?
    if(!$connessioneDB)
    	{
    	if(!$home) $home="../../";
    	$connessioneDB=$home."Connections/database.php";
    	require_once($connessioneDB);
    	mysql_select_db($database, $databaseSito); 
    	}
    if (isset($HTTP_COOKIE_VARS["AUTENTICAZIONE_username"])) {
    $AUTENTICAZIONE_username = $HTTP_COOKIE_VARS["AUTENTICAZIONE_username"];
    $AUTENTICAZIONE_password = $HTTP_COOKIE_VARS["AUTENTICAZIONE_password"];
    $autenticazione = $HTTP_COOKIE_VARS["AUTENTICAZIONE"];
    } else {
    $autenticazione = 0;
    }
    ?>
    <?
    	if(!$autenticazione)
    		{
    		$AUTENTICAZIONE_username=$username;
    		$AUTENTICAZIONE_password=$password;
    		}
    	$query = "SELECT * FROM utenti WHERE username='$AUTENTICAZIONE_username' AND password='$AUTENTICAZIONE_password'";
    	$result = mysql_query($query); 
    	$row = mysql_num_rows($result);
    	if ($row) {
    		
    		// stabilisci durata dei cookie
    		
    		$newtime = time()+3600; //default è un'ora
    
    		setcookie ("AUTENTICAZIONE_username", $AUTENTICAZIONE_username, $newtime);
    		setcookie ("AUTENTICAZIONE_password", $AUTENTICAZIONE_password, $newtime);
    		setcookie ("AUTENTICAZIONE", "1", $newtime);
    		
    		
    		// descrizione costanti
    		$result = mysql_query ("SELECT * FROM utenti WHERE username='$AUTENTICAZIONE_username'", $databaseSito) or die(mysql_error());
    		$row = mysql_fetch_assoc($result);
    		$AUTENTICAZIONE_id			= $row['cont'];
    		$AUTENTICAZIONE_username	= $row['username'];
    		//$AUTENTICAZIONE_password	= $row['password'];
    		$AUTENTICAZIONE_nome 		= $row['nome'];
    		$AUTENTICAZIONE_telefono	= $row['telefono'];
    		$AUTENTICAZIONE_email		= $row['email'];
    		$AUTENTICAZIONE_zona		= $row['zona'];
    		$AUTENTICAZIONE_squadra		= $row['squadra'];
    		// fine dichiarazione costanti
    		
    	} else  //se autenticazione fallisce
    	{
    		if(strcmp($PHP_SELF,"/amministrazione/index.php")!=0)
    			{
    			?>
    			<html>
    			<head>
    			<script language="JavaScript" type="text/JavaScript">
    			<!--
    			function MM_goToURL() { //v3.0
    			  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    			  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    			}
    			//-->
    			</script>
    			</head>
    			<body onLoad="MM_goToURL('parent','index.php');return document.MM_returnValue">
    			</body>
    			</html>
    			<?
    			$AUTENTICAZIONE_redirect=1010;	
    			}
    		
    	}
    	// vai all'indirizzo se richiesto
    	if ($indirizzo != "" && !$AUTENTICAZIONE_redirect) {
    	?>
    	<html>
    	<head>
    	<script language="JavaScript" type="text/JavaScript">
    	<!--
    	function MM_goToURL() { //v3.0
    	  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    	}
    	//-->
    	</script>
    	</head>
    	<body onLoad="MM_goToURL('parent','<? echo $indirizzo; ?>');return document.MM_returnValue">
    	</body>
    	</html>
    
    	<?
    	}
    	?>
    <?
    // ripresa variabili indispensabili
    	$autenticazione = $HTTP_COOKIE_VARS["AUTENTICAZIONE"];
    	$AUTENTICAZIONE_username = $HTTP_COOKIE_VARS["AUTENTICAZIONE_username"];
    	$AUTENTICAZIONE_password = $HTTP_COOKIE_VARS["AUTENTICAZIONE_password"];
    ?>
    |--- |--- |- |---
    | | | \ |
    |-- |-- | | |--
    | | | / |
    | |--- |- |---

  4. #4
    Utente bannato
    Registrato dal
    Sep 2005
    Messaggi
    905
    che versione di php usi? ho visto che usi http_cookie_vars al posto di $_COOKIE...

  5. #5
    Io uso easyPHP e nelle opzioni mi dice che ho il 4.2..
    ma sui server ARUBA (in cui ho il sito) non so che versione sia installata.

    Ma è corretto il comando per salvare i cookie?

    come funziona $_COOKIE???
    |--- |--- |- |---
    | | | \ |
    |-- |-- | | |--
    | | | / |
    | |--- |- |---

  6. #6
    Utente bannato
    Registrato dal
    Sep 2005
    Messaggi
    905
    basta sostituire $HTTP_COOKIE_VARS con $_COOKIE

  7. #7
    niente, vorrà dire che cambio metodo di autenticazione!!

    uffi :-((


    grazie mille php_34 per il tuo aiuto!
    |--- |--- |- |---
    | | | \ |
    |-- |-- | | |--
    | | | / |
    | |--- |- |---

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.