Welcome Guest, Not a member yet? Register   Sign In
Using the Sessiong class
#1

[eluser]RandyJP[/eluser]
Hello, Its my first time using codeigniter and also this class. I have the CI_session table in my database and I'm adding some custom data to the array that de new session creates.

Code:
$newdata = array(
                                'tipo_usuario'  => $tipo['tipo'],//Add  the user type

                                'habitacion'   => $tipo['habitacion'],//Add the room

                                'usuario'      => true               //creo the session  
                                             );
                            $this->session->set_userdata($newdata);


this is ok, and I can get anything from the array as long as its call within the same controller that created it. But this array is suppose to run globally as long as I initialize the Session class manually in the controller constructor. But I'm doing this in and other and its not working

Code:
$hab=$this->session->userdata('habitacion'); //room number

this is suppose to return a number but I doesn't outside the controller. How do I do to have the array globally?? can I do it?
#2

[eluser]InsiteFX[/eluser]
If your using the session class then autoload it in ./application/config/autoload.php
#3

[eluser]RandyJP[/eluser]
Still nothing outside the main controller where I create the array is like the array doesn't exits
#4

[eluser]RandyJP[/eluser]
Anyone???
#5

[eluser]Samus[/eluser]
Use profiler to confirm?
#6

[eluser]RandyJP[/eluser]
[quote author="Samus" date="1334514260"]Use profiler to confirm?[/quote]


What do you mean?? What's profiler??
#7

[eluser]Samus[/eluser]
I generally use it whenever i'm developing. It helps greatly when debugging.

Have a read:

http://ellislab.com/codeigniter/user-gui...iling.html
#8

[eluser]Reneesh T K[/eluser]
autoload session in autoload.php page in config folder like the below

$autoload['libraries'] = array('database','session','form_validation','pagination','email');


Check the config table and check for is session is using database:

$config['sess_cookie_name'] = 'ci_frontend_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_frontend_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;

If it is using database, check is anything entering to the table when a page loads.

I think there is no need to include session in each page. If it is loading in autoload.php page, it is working normally.




Theme © iAndrew 2016 - Forum software by © MyBB