• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PROBLEM] $this->load->library(array('session'));

#1
[eluser]wafaa[/eluser]
Hi all,

Please I need a very quick answer to my question!!

I have a problem with using session library, I have a class where I need to use session library.
Everything works well but when I do that
Code:
$this->load->library(array('session'));
$this->session->set_userdata('data', $data['adherent_tb']);
I have a bug when I remove that that works!

I tried to place this line of code averywhere but I always have the same problem!!

Why
Code:
$this->load->library(array('session'));
generates problems ?!!!!!!!!!!!

and is it true that sessions are destroyed when we leave the controller they were created in ?

Thank you for help

#2
[eluser]Pooof[/eluser]
eso es porque tenes que cargarla asi $this->load->library(session);
y eso si funciona (desde el controller)

#3
[eluser]Ebot Ndip-Agbor[/eluser]
Use
Code:
$this->load->library('session');

#4
[eluser]wafaa[/eluser]
Thanks for your answer

$this->load->library(array('session'));
is not the problem

I tried with $this->load->library('session');

and it didn't work too!

Any other opinion?

thx a lot

#5
[eluser]wafaa[/eluser]
I will give you all of my class code so that you can see better:

Code:
<?php
class A_qui_modif_controller extends Controller
{    
    function A_qui_modif_controller()
    {
        parent::Controller();            
    }

    function index()
    {
        $this->load->helper(array('form','url'));
        
        $rules_['nom']    = "trim|required";
        $rules_['prenom']    = "trim|required";    
            
        $this->load->library(array('session', 'validation'));        
        $this->validation->set_rules($rules_);
        

        //validations rules nn respectes on recharge le form        
        if ($this->validation->run() == FALSE)
        {
            $this->load->view('projet/a_qui_modif_view');
        }
        else
        {            
            //on extrait les infos saisies par le form et on balance le tt au controller de consultation
            $nom=$_POST['nom'];            
            $prenom=$_POST['prenom'];
                        
            $sql1 = "SELECT * FROM adherent WHERE nom=? AND prenom=?";
            
            $this->load->database();
            $data['adherent_tb']=$this->db->query($sql1, array($nom, $prenom));        
            
            
            $this->load->library(session);
            
            //on met le tt ds la session    
            $this->load->library('session');
            $this->session->set_userdata('data', $data['adherent_tb']);    
            
            $this->load->model('projet/a_modif_model');        
            $this->a_modif_model->index();        
        }
    }    
}
?>

#6
[eluser]Ebot Ndip-Agbor[/eluser]
Quote:
Code:
$this->load->library(session);
            
            //on met le tt ds la session    
            $this->load->library('session');
            $this->session->set_userdata('data', $data['adherent_tb']);    
            
            $this->load->model('projet/a_modif_model');        
            $this->a_modif_model->index();        
        }
    }    
}
?>
remove this line from your code and try again
Code:
$this->load->library(session);

#7
[eluser]wafaa[/eluser]
[quote author="batangai" date="1205799815"]
Quote:
Code:
$this->load->library(session);
            
            //on met le tt ds la session    
            $this->load->library('session');
            $this->session->set_userdata('data', $data['adherent_tb']);    
            
            $this->load->model('projet/a_modif_model');        
            $this->a_modif_model->index();        
        }
    }    
}
?>
remove this line from your code and try again
Code:
$this->load->library(session);
[/quote]


No this is not my error! I just forgot to remove it.
My error was that i put
Code:
$this->session->set_userdata('data', $data['adherent_tb']);
instead of this
Code:
$this->session->set_userdata('data', $data

Now it works but I still have the famous error in my view:

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\codeigniter_1.6.1\system\libraries\Input.php:1)

Filename: libraries/Session.php

Line Number: 295


So... does some one know why ?!

#8
[eluser]Ebot Ndip-Agbor[/eluser]
maybe that is because you loaded the session library twice~?! 8-/


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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