Welcome Guest, Not a member yet? Register   Sign In
My own session data not stored
#1

[eluser]Keem1[/eluser]
Hi,

I've created (sorry, tried to create) a very simple login method for user login, now just store the session data, but not works.
If you call the login method, your session data will store, but navigate other url in this website, the custom session data will lost.

The code in login controller (not access to database yet), it's a plan:
Code:
function belepes()
{
    $this->session->sess_destroy();
    $this->session->sess_create();
    $session_array = array(
        "username"=>"keem1"
        );
    $this->session->set_userdata($session_array);
    print "Sikeres belépés, ".$this->session->userdata('username')." (".$this->session->userdata('ip_address').")!<br />";    
}

function kivagyok()
{
    print "Belépve ".$this->session->userdata('username')." néven";
        // Prints the text "Logged in with xy username"
    // But now returns with nothing - that's the problem...
}

function kilepes()
{
    $this->session->sess_destroy();
}

Help for hungarian words:
- belepes() = login
- kilepes() = logout
- kivagyok() = who_am_i, checking the logged status

My session configuration in config.php:
Code:
$config['sess_cookie_name']                = 'cisession';
$config['sess_expiration']                = 7200;
$config['sess_encrypt_cookie']        = FALSE;
$config['sess_use_database']        = FALSE;
$config['sess_table_name']                = 'im__sessions';
$config['sess_match_ip']                = FALSE;
$config['sess_match_useragent']        = FALSE;
$config['sess_time_to_update']                 = 300;

My tests:
- navigate to http://mysite/index.php/login/belepes/ to login
- navigate to http://mysite/index.php/login/kivagyok/ to check data after navigating to other page

While I'm logging in by calling the belepes() (login) method, the username will get back correctly (keem1). But I will navigate the next method, kivagyok() (who_am_i), all original session data (ip, user agent, and so on) return the correct value, but my own data, the username will return with empty.
I've thought this is a very simple test without using database, but it seems, I have a very-very big mistake.

What's wrong?
#2

[eluser]TheFuzzy0ne[/eluser]
Are you sure that you're not calling the login function more than once? That would reset the session and explain your problem.




Theme © iAndrew 2016 - Forum software by © MyBB