Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter lost my session
#1

[eluser]Lokut Da[/eluser]
Hey!

I have a problem with CI.

CI sometimes lose my session and do not know why. I think, CI supports a maximum bytes of sessions. I guess...

What do u think?

Thanks in advance.
#2

[eluser]InsiteFX[/eluser]
Use database sessions!

Cookies 4kb, but some browsers have raised the limit.

InsiteFX
#3

[eluser]CI_avatar[/eluser]
what are the values saved in CI sessions?
#4

[eluser]minhbu[/eluser]
pls try native session

http://codeigniter.com/wiki/Native_session/
#5

[eluser]Lokut Da[/eluser]
Hey! thanks for ur answers Smile

Let me check the database sessions and will coment about that.

Regards.
#6

[eluser]WanWizard[/eluser]
[quote author="minhbu" date="1282826298"]pls try native session

http://codeigniter.com/wiki/Native_session/[/quote]
Why? What does this solve?
#7

[eluser]Lokut Da[/eluser]
Hi again...

I checked the database session and I continue with the same problem Sad

I writed the next code in my controller:

Code:
public function index()
    {
        $addDatos = array( 'usuario' => array('id'=>1, 'nombre'=>'Androu Fallou Da Locu', 'identidad'=>'2222222', 'nick'=>'Locut Da', 'oficina'=>'Seed' ), 'makemake' => 1, 'mekemeke' => 1, 'mikemike' => 1, 'mokemoke' => 1, 'mukemuke' => 1, 'fay' => 1, 'fey' => 1, 'fiy' => 1, 'foy' => 1, 'fuy' => 1, 'dad' => 1, 'ded' => 1, 'did' => 1, 'dod' => 1, 'dud' => 1, 'tat' => 1, 'tet' => 1, 'tit' => 1, 'tot' => 1, 'tut' => 1 );

        //inicializar el array en una sesión de CI
        $this->session->set_userdata('usuarioLogin', $addDatos);

        echo '<pre>'.print_r($this->session->userdata('usuarioLogin'), true).'</pre>';

        $this->load->view('probando_index');
    }

When I do update on my browser on index page, I can see the result:

Code:
Array
(
    [usuario] => Array
        (
            [id] => 1
            [nombre] => Androu Fallou Da Locu
            [identidad] => 2222222
            [nick] => Locut Da
            [oficina] => Seed
        )

    [makemake] => 1
    [mekemeke] => 1
    [mikemike] => 1
    [mokemoke] => 1
    [mukemuke] => 1
    [fay] => 1
    [fey] => 1
    [fiy] => 1
    [foy] => 1
    [fuy] => 1
    [dad] => 1
    [ded] => 1
    [did] => 1
    [dod] => 1
    [dud] => 1
    [tat] => 1
    [tet] => 1
    [tit] => 1
    [tot] => 1
    [tut] => 1
)

But if I change to the page "procesar.php":

Code:
public function procesar()
    {
        echo '<pre>'.print_r($this->session->userdata('usuarioLogin'), true).'</pre>';
    }

I can't see my session array Sad.

What do u think?

Regards.
#8

[eluser]bretticus[/eluser]
Is "processar.php" a controller file? Or do you browse directly to that file?
#9

[eluser]Lokut Da[/eluser]
Hi bretticus...

My controller is "probando". Sorry, let me to post the complete code of my controller:

Code:
class Probando extends Controller
{
    public function  __construct()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->library('session');
    }

    public function index()
    {
        $addDatos = array( 'usuario' => array('id'=>1, 'nombre'=>'Androu Fallou Da Locu', 'identidad'=>'2222222', 'nick'=>'Locut Da', 'oficina'=>'Seed' ), 'makemake' => 1, 'mekemeke' => 1, 'mikemike' => 1, 'mokemoke' => 1, 'mukemuke' => 1, 'fay' => 1, 'fey' => 1, 'fiy' => 1, 'foy' => 1, 'fuy' => 1, 'dad' => 1, 'ded' => 1, 'did' => 1, 'dod' => 1, 'dud' => 1, 'tat' => 1, 'tet' => 1, 'tit' => 1, 'tot' => 1, 'tut' => 1 );

        //inicializar el array en una sesión de CI
        $this->session->set_userdata('usuarioLogin', $addDatos);

        echo '<pre>'.print_r($this->session->userdata('usuarioLogin'), true).'</pre>';

        $this->load->view('probando_index');
    }

    public function procesar()
    {
        echo $this->input->post('usuario');
        echo '<br />';
        echo $this->input->post('contrasena');
        //echo '<pre>'.print_r($this->session->userdata('usuarioLogin'), true).'</pre>';
        echo $this->session->userdata('usuarioLogin');
    }
}
#10

[eluser]tkyy[/eluser]
as the first response said you should use database sessions. the only reason not to use database sessions is the very, very slight overhead from the extra queries. being able to store virtually unlimited amounts of data into the secure database is surely a win over storing the encrypted values into a cookie with a set length.

the first social networking site i coded did just that, stored a massive amount of data into the cookie. my users table got so large that i eventually had to pick and choose which values i needed to store in the database because it wasn't creating the sessions properly since it made the cookie explode.

eeeeek, avoid the mistakes i made please.




Theme © iAndrew 2016 - Forum software by © MyBB