Ver Mensaje Individual
  #6 (permalink)  
Antiguo 02/07/2014, 20:29
Avatar de arcanisgk122
arcanisgk122
 
Fecha de Ingreso: junio-2010
Mensajes: 755
Antigüedad: 13 años, 11 meses
Puntos: 28
Respuesta: Eror con $_SESSION

Disculpa si dudo de lo que argumentas pero por que dices que no puede estar session_start() dentro de alguna funcion o script, que yo entienda después que su llamada este al inicio del código no debe haber ningún problema:

index.php
Código PHP:
Ver original
  1. /*incluciones de codigo del core php y las clases mediate uso de constantes*/
  2. require_once("config/index.config.php");
  3.  
  4. //instanciamos las clases
  5. $sesion     =   new Session();
  6. $language   =   new Language();
  7.  
  8.  
  9.  
  10. $sesion ->  iniciarSession();//iniciamos sesion
  11. $lang = $language->getLanguage(@$_POST['lang']);//obtenemos lenguaje y actualisamos

config/index.config.php

Código PHP:
Ver original
  1. <?php
  2.     //Directorio del nucleo de PHP
  3.     $APP_PHPCORE_DIR=$_SERVER['DOCUMENT_ROOT'] . '/phpcore';
  4.     //Lenguaje por defecto
  5.     $DEFAULT_LANGUAGE = 'es';
  6.     $LANGUAGE_DIR='/lang';
  7.     //Cargamos todos los archivos del núcleo php que se utilizaran
  8.     require_once $APP_PHPCORE_DIR . '/' . 'class.constants.php';
  9.     require_once $APP_PHPCORE_DIR . '/' . SESSION_CLASS;
  10.     require_once $APP_PHPCORE_DIR . '/' . LANGUAGE_CLASS;
  11.     require_once $APP_PHPCORE_DIR . '/' . CHARGETPL_CLASS;
  12.     require_once $APP_PHPCORE_DIR . '/' . MERGETPL_CLASS;
  13.     require_once $APP_PHPCORE_DIR . '/' . PRINTTPL_CLASS;
  14. ?>

class.constants.php
Código PHP:
Ver original
  1. <?php
  2.     /*definimos las Constantes de la pagina web*/
  3.     define("SESSION_CLASS"      ,"class.session.php");
  4.     define("LANGUAGE_CLASS"     ,"class.language.php");
  5.     define("CHARGETPL_CLASS"    ,"class.chargTPL.php");
  6.     define("MERGETPL_CLASS"     ,"class.mergeTPL.php");
  7.     define("PRINTTPL_CLASS"     ,"class.printTPL.php");
  8. ?>


class.session.php
Código PHP:
Ver original
  1. <?php
  2. class Session{
  3.     function iniciarSession(){
  4.         session_name('NombredeSession');
  5.         session_start();
  6.         // Turn on all error reporting
  7.         error_reporting(E_ALL);
  8.     }
  9. }
  10. ?>


class.language.php
Código PHP:
Ver original
  1. <?php
  2.     class Language {
  3.         //  Method to detect user language
  4.         function detectLanguage() {
  5.             global $DEFAULT_LANGUAGE;
  6.             if ($_SERVER['HTTP_ACCEPT_LANGUAGE']) {
  7.                 $this->languages = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  8.                 $this->language = substr($this->languages,0,2);
  9.                 echo "si acepta HTTP_ACCEPT_LANGUAGE<br>";
  10.                 return $this->language;
  11.             }else{
  12.                 echo "no acepta HTTP_ACCEPT_LANGUAGE<br>";
  13.                 if ($_SERVER['HTTP_USER_AGENT']) {
  14.                     echo "si acepta HTTP_USER_AGENT<br>";
  15.                     $this->user_agent = explode(";" , $_SERVER['HTTP_USER_AGENT']);
  16.                     for ($i=0; $i < sizeof($this->user_agent); $i++) {
  17.                         $this->languages = explode("-",$this->user_agent[$i]);
  18.                         if (sizeof($this->languages) == 2) {
  19.                             if (strlen(trim($this->languages[0])) == 2) {
  20.                                 $size = sizeof($this->language);
  21.                                 $this->language[$size]=trim($this->languages[0]);
  22.                             }
  23.                         }
  24.                     }
  25.                     return $this->language[0];
  26.                 }else{
  27.                     echo "no acepta HTTP_USER_AGENT<br>";
  28.                     $this->language = $DEFAULT_LANGUAGE;
  29.                     return $this->language;
  30.                 }
  31.             }
  32.         }
  33.         //  Method to check if a language exists
  34.         function checkLanguage($language = null) {
  35.             global $LANGUAGE_DIR;
  36.             echo "verificamos si existen los archivos de lenguaje <br>";
  37.             $language = $LANGUAGE_DIR."/".$language.".inc.php";
  38.             if (file_exists($language)){
  39.                 return TRUE;
  40.             }else{
  41.                 return FALSE;
  42.             }
  43.         }
  44.         //Method to set language
  45.         function setLanguage($language = null){
  46.             echo "asignacion de lenguaje <br>";
  47.             global $DEFAULT_LANGUAGE;
  48.             if ($language){ $_SESSION['LANGUAGE'] = $language;}
  49.             if (@!$_SESSION['LANGUAGE']){ $_SESSION['LANGUAGE'] = $this->detectLanguage();}
  50.             if ($this->checkLanguage($_SESSION['LANGUAGE'])) {
  51.                 $lang =  $_SESSION['LANGUAGE'];
  52.                 return $lang;
  53.             }else{
  54.                 return $DEFAULT_LANGUAGE;
  55.             }
  56.         }
  57.         //Method to get the language configuration
  58.         function getLanguage($language = null) {
  59.             echo "obtenemos la configuracion del lenguaje <br>";
  60.             global $LANGUAGE_DIR;
  61.             $lang = $this->setLanguage($language);
  62.             include_once $LANGUAGE_DIR."/".$lang.".inc.php";
  63.             return $language = $lang;
  64.         }      
  65.     }
  66. ?>

problema resuelto. esto es MVC y POO, si alguien tiene algún aporte o sugerencia pues la tomare en cuenta.
__________________
Cooler Master Gladiator 600 - AMD PHENOM II X4 955 @ 3.5GHZ
GA-MA78GM-US2H - Super Talent 800 2GB x 2 Dual, (Unganged)
PSU Cooler Master eXtreme Power Plus 500W - Saphire R7-260OC-2GB