Welcome Guest, Not a member yet? Register   Sign In
Problem with 'session'
#1

[eluser]Kadu[/eluser]
Im not so good in english, but i'll try.
I'm having some trouble with an aplication that i'm developping... when i try to pass some value to a session variable, i get an error...

my code:

Code:
$this->load->library('session');
                
$this->session->set_userdata('cod_usuario', $row->cod_usuario);

my error:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Login::$session

Filename: login/login.php

Line Number: 70

my php error:
Quote:Fatal error: Call to a member function set_userdata() on a non-object in C:\Documents and Settings\Administrador\Meus documentos\www\CodeIgniter\system\application\controllers\login\login.php on line 70

I'm new in CI... and trying to learn... and this is making me angry...

Thanks for respond...
#2

[eluser]gtech[/eluser]
has $row->cod_usuario been set... you could just try
Code:
..
// assuming inside controller function
$this->load->library('session');
$this->session->set_userdata('cod_usuario', 'atest');
echo $this->session->userdata('cod_usuario');
..
if that works then you know that your $row data has not been set properly.
#3

[eluser]Kadu[/eluser]
$row->cod_usuario is set... it receives an integer value. Even passing another value (example:'atest') it don't works. It gives me the same error.
#4

[eluser]Kadu[/eluser]
OK... I found the problema... I was loading the library 'session' in the autoloader file. I don't know why, but when I get it off, the session works.
#5

[eluser]gtech[/eluser]
ah I never thought about that! well nice to know what happens when you load the session library twice, might help someone else with the same problem.
#6

[eluser]weedy[/eluser]
I have this problem while autoloading session but NOT loading it twice.. ideas?
#7

[eluser]gtech[/eluser]
[strike]
I havn't a clue, it works for me on 1.6.1 when I autoload it.. maybee this is what I would try if I was in your shoes:

Turn on logging threashold, to the highest setting in the config, see if there are any log meesages being produced in the log files, it may higlight an error when loading.

try autoloading session by adding it into the autoload config instead of loading it in the controller, then swap it around see if one or the other works, then let us know how you get on, unless anyone has come across this before.
[/strike]
[edit]
ah hang on I see you started another thread, nice catch by the way.
[url="http://ellislab.com/forums/viewthread/79175/"]http://ellislab.com/forums/viewthread/79175/[/url]
[/edit]




Theme © iAndrew 2016 - Forum software by © MyBB