Ver Mensaje Individual
  #12 (permalink)  
Antiguo 12/04/2012, 10:39
Avatar de ahaugas
ahaugas
 
Fecha de Ingreso: agosto-2011
Ubicación: Madrid
Mensajes: 249
Antigüedad: 12 años, 8 meses
Puntos: 21
Respuesta: necesito informacion para separar sesiones en php?

perdona, pero no sabria decirte donde hago un asignacion de la sesion, intento aprender todavia las sesiones y phpoo

los codigos que he rastreado

function isUserLoggedIn()



Código PHP:
Ver original
  1. function isUserLoggedIn() {
  2.     global $loggedInUser, $db, $db_table_prefix;
  3.  
  4.     if ($loggedInUser == NULL) { return false; }
  5.     else {
  6.         $sql = "SELECT User_ID,
  7.                Password
  8.                FROM " . $db_table_prefix . "Users
  9.                WHERE
  10.                User_ID = '" . $db->sql_escape($loggedInUser->user_id) . "'
  11.                AND
  12.                Password = '" . $db->sql_escape($loggedInUser->hash_pw) . "'
  13.                AND
  14.                Active = 1
  15.                LIMIT 1";
  16.  
  17.         //Query the database to ensure they haven't been removed or possibly banned?
  18.         if (returns_result($sql) > 0) { return true; }
  19.         else {
  20.             //No result returned kill the user session, user banned or deleted
  21.             $loggedInUser->userLogOut();
  22.  
  23.             return false;
  24.             }
  25.         }
  26.     }

function destorySession()

Código PHP:
Ver original
  1. function destorySession($name)
  2.     {
  3.         if(isset($_SESSION[$name]))
  4.         {
  5.             $_SESSION[$name] = NULL;
  6.            
  7.             unset($_SESSION[$name]);
  8.         }
  9.     }

function userLogOut()

Código PHP:
Ver original
  1. function userLogOut()
  2.     {
  3.         destorySession("userCakeUser");
  4.     }

y el login php

Código PHP:
Ver original
  1. if(!empty($_POST))
  2. {
  3.         $errors = array();
  4.         $username = trim($_POST["username"]);
  5.         $password = trim($_POST["password"]);
  6.    
  7.         //Perform some validation
  8.         //Feel free to edit / change as required
  9.         if($username == "")
  10.         {
  11.             $errors[] = lang("ACCOUNT_SPECIFY_USERNAME");
  12.         }
  13.         if($password == "")
  14.         {
  15.             $errors[] = lang("ACCOUNT_SPECIFY_PASSWORD");
  16.         }
  17.        
  18.         //End data validation
  19.         if(count($errors) == 0)
  20.         {
  21.             //A security note here, never tell the user which credential was incorrect
  22.             if(!usernameExists($username))
  23.             {
  24.                 $errors[] = lang("ACCOUNT_USER_OR_PASS_INVALID");
  25.             }
  26.             else
  27.             {
  28.                 $userdetails = fetchUserDetails($username);
  29.            
  30.                 //See if the user's account is activation
  31.                 if($userdetails["Active"]==0)
  32.                 {
  33.                     $errors[] = lang("ACCOUNT_INACTIVE");
  34.                 }
  35.                 else
  36.                 {
  37.                     //Hash the password and use the salt from the database to compare the password.
  38.                     $entered_pass = generateHash($password,$userdetails["Password"]);
  39.  
  40.                     if($entered_pass != $userdetails["Password"])
  41.                     {
  42.                         //Again, we know the password is at fault here, but lets not give away the combination incase of someone bruteforcing
  43.                         $errors[] = lang("ACCOUNT_USER_OR_PASS_INVALID");
  44.                     }
  45.                     else
  46.                     {
  47.                         //Passwords match! we're good to go'
  48.                        
  49.                         //Construct a new logged in user object
  50.                         //Transfer some db data to the session object
  51.                         $loggedInUser = new loggedInUser();
  52.                         $loggedInUser->email = $userdetails["Email"];
  53.                         $loggedInUser->user_id = $userdetails["User_ID"];
  54.                         $loggedInUser->hash_pw = $userdetails["Password"];
  55.                         $loggedInUser->display_username = $userdetails["Username"];
  56.                         $loggedInUser->clean_username = $userdetails["Username_Clean"];
  57.                        
  58.                         //Update last sign in
  59.                         $loggedInUser->updateLastSignIn();
  60.        
  61.                         $_SESSION["userCakeUser"] = $loggedInUser;
  62.                        
  63.                         //Redirect to user account page
  64.                         header("Location: account.php");
  65.                         die();
  66.                     }
  67.                 }
  68.             }
  69.         }
  70.     }
  71. ?>

alomejor ya se declara en el login php al introducir los datos y por eso hace conflicto.