Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Call to undefined method CI_Session::user_data()
#1

[eluser]Gijs Bloemen[/eluser]
Hi all,

I am trying to use sessions in codeigniter and when I have putted something in a session and I called it with the $this->session->user_data(..) it gives this error: Fatal error: Call to undefined method CI_Session::user_data()

Below I putted my code, but I stripped everything away that has to do nothing with the sessions:

Code:
//Load the session library
$this->load->library('session');

//Define variable username and variable rand
$username    = $this->form_validation->set_rules('username' ,'trim');

$rand    =    rand(0,999999);

//Putting this in an array
$session_data = array (
                'username'    => $username,
                'u_id'        => $rand,
            );

//Put the array in a session            
$this->session->set_userdata($session_data);

//Get the information out of the session (this part of the code is putted in an other //controller, ofcourse I also loaded in this controller the session library)
$data    =    array (
                'session_username'     => $this->session->user_data('username'),
                'session_rand'        => $this->session->user_data('rand'),
                'title'                => 'Hoofdkwartier',
            );

I got the error on the line where is placed 'session_username'=> $this->session->user_data('username'),

Regards,
Gijs Bloemen

(Sorry for my bad English)
#2

[eluser]Cro_Crx[/eluser]
remove the underscores. should be

Code:
$data    =    array (
                'session_username'     => $this->session->userdata('username'),
                'session_rand'        => $this->session->userdata('rand'),
                'title'                => 'Hoofdkwartier',
            );
#3

[eluser]Gijs Bloemen[/eluser]
[quote author="Cro_Crx" date="1247510859"]remove the underscores. should be

Code:
$data    =    array (
                'session_username'     => $this->session->userdata('username'),
                'session_rand'        => $this->session->userdata('rand'),
                'title'                => 'Hoofdkwartier',
            );
[/quote]

Thanks, indeed, didn't see it.. Stupid fault...
#4

[eluser]Cro_Crx[/eluser]
[quote author="Gijs Bloemen" date="1247514534"]Thanks, indeed, didn't see it.. Stupid fault...[/quote]

It's all good, I do that one myself a lot. That and writing $this->validation instead of form_validation!
#5

[eluser]TheFuzzy0ne[/eluser]
You should be able to safely delete the validation.php file so long as you don't use it anywhere else in your code, since it's deprecated. That way, you'll get a helpful error message whenever you try to use it.
#6

[eluser]levani[/eluser]
******************




Theme © iAndrew 2016 - Forum software by © MyBB