Welcome Guest, Not a member yet? Register   Sign In
Session Disappear
#1
Sad 

I set the session variable but it disappears. $data in setsession function is a result of a query (row_array).

I have seen this site linked below and I am using SlimBrowser (Chrome copy) in Windows Localhost. Is there a change in this situation stated in the page? I started CI a few days ago now I am planning to never use it again??? I have been trying to understand how a session disappears and gave hours on that... Angry

http://billpatrianakos.me/blog/2013/03/2...-problems/

setting function:
PHP Code:
public function setsession($data){
        
$this->session->set_userdata("user_data",$data);
        
$this->session->set_userdata('logged_in',true);
        
print_r($this->session->all_userdata());
        
//$data=$this->session->all_userdata();
    


Checking function:
PHP Code:
public function isloggedin()
    {
        
$data=$this->session->userdata("logged_in");
        if(
$data==false){
            return 
false;
        }
        return 
true;
    } 

I would be grateful if someone can help.
Reply
#2

(This post was last modified: 12-29-2014, 10:35 AM by Avenirer.)

First of all you should make sure you've loaded the session library/driver.

So, if you didn't autoload it, you can load it inside the two functions.

Now... if you have CI 2.x... you can load it with 
PHP Code:
$this->load->library('session'); 

If you have CI 3.dev you can load it with
PHP Code:
$this->load->driver('session'); 

Worth mentioning...
if setsession() method is called from the controller and not from browser you should make the function (method) private...
Reply
#3

set_session method is in model. and I have already included session in model and controller.

Still session variable disappears.
Reply
#4

OK. I switched to using PHP's session variable.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB