Welcome Guest, Not a member yet? Register   Sign In
Problems with the session library
#1

[eluser]Maestro[/eluser]
Hi Everyone,

I have a very strange error. See the code:

Code:
class LoginUser extends Controller {

    function Privacy()
    {
        parent::Controller();
    }
    
    function index()
    {    
           $this->user->login($_POST["login"], $_POST["pass"]);
           print $this->session->userdata("myvar");
    }
}

class CI_User {
...
    function CI_User()
    {
           $this->_ci_initialize();
    }

    function _ci_initialize()
    {
           $this->CI =& get_instance();
           $this->CI->load->library('session');
        }

    function login($login, $pass)
    {
           $this->CI->session->set_userdata("myvar", "hello, world");
           return "";
    }
...

This way I see the variable "myvar" on the Login page. But I do not see this variable on the other pages such as a main page. Where did I do a mistake?
#2

[eluser]Maestro[/eluser]
I think it occured because I commented this line:

Code:
if ($this->sess_use_database === FALSE)
{
    //$this->_set_cookie();
    return;
}

but I do not want to use a cookie for a session. I need a very big arrays for my session. What best way to solve this problem?
#3

[eluser]Dam1an[/eluser]
Use databases for userdata then, just enable it in the config file, create the database table (Schema for table is at the bottom of tthis page) and the rest works as normal
#4

[eluser]Maestro[/eluser]
Thank you! I searched for this information right now. Smile




Theme © iAndrew 2016 - Forum software by © MyBB