• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sessions ci

#1
[eluser]Miky llanderal[/eluser]
hello everybody, i have an issue with the session, the principal problem with this is that when i click an anchor link, the user_data is deleted i'll show you the code:
Code:
class Inicio extends Controller {

    function  __construct() {
        parent::Controller();
    }

    function index($msg='') {
        $data['msg']=$msg;
        $lastExitos = new Caso_exito_model();
        $lastExitos = $lastExitos->getExitosResumidos();
        $lastNoticias = new Ultima_noticia_model();
        $lastNoticias = $lastNoticias->getUltimasNoticias();

        $data = array(
            'lastExitos' => $lastExitos,
            'lastNoticias' => $lastNoticias,
            'msg'=>$msg
        );

        $this->load->view('inicio_view', $data);
    }
    function virtual(){
         $data['head']="consultoria/header";
         $data['foot']="footera";
         $data['panel_left']="consultoria/panel_left_view";
         if($this->session->userdata('logged_in') === TRUE){
            $data['content'] = "consultoria/container";
            $data['autodiagnostico']="http://www.url.lala/index.asp";
            $this->load->view('general_inst', $data);
         }
         else{
             redirect('/inicio/registro/', 'refresh');
         }
    }
    function login(){
        $user=$this->input->post('username');
        $pass=$this->input->post('password');
          
            $this->load->model('usuario_model');
        $log=$this->usuario_model->autenticar($user, md5($pass));
        if($log!=false){
          foreach($log->all as $row){
        $user_data=md5($row->id."&".$row->email);
              
          }
          $data = array(
                  'user_data'  => $user_data,
          'logged_in'  => TRUE
          );
          $this->session->set_userdata($data);
          //Actualizar session table
          $session_id = $this->session->userdata('id');
              
          $upd_session=$this->session_model->loggedin($data['user_data'],$session_id);
          if($upd_session=="done"){
        $this->acceso();
          } else {
        $this->index('<div id="message">El nombre de usuario y/o contraseña es incorrecto, intente de nuevo.</div>');
          }
        } else {
          $this->index('<div id="message">El nombre de usuario y/o contraseña es incorrecto, intente de nuevo.</div>');
        }
    }
        function logout()
    {
      $this->session->sess_destroy();
          $this->index('<div id="message">La sesión se ha cerrado exitosamente.</div>');
    }
function acceso() {
if($this->session->userdata('logged_in') === TRUE){
   $this->virtual();

}
}

I put the function acceso only for testing purposes and the first time it works well but when im in the page showed by virtual function and i click in one link the session it's erased and i get other session_id and this is something weird! i'll show you the configuration:

autoload:
Code:
$autoload['libraries'] = array('database', 'datamapper','session');

config file:
Code:
$config['sess_cookie_name']        = 'micrositiovinculacion';
$config['sess_expiration']        = 0;
$config['sess_encrypt_cookie']    = TRUE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'session';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = FALSE;
$config['sess_time_to_update']     = 7200;

and i use the table showed in the user guide

anyone knows why is it happen?

#2
[eluser]WanWizard[/eluser]
Please don't ask the same question twice...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.