Welcome Guest, Not a member yet? Register   Sign In
CI Sessions - No user data
#11

[eluser]toopay[/eluser]
Just do this simple test. Make some controller to display session data. And then, check if the session_id changed, if you instantly refresh the page.
#12

[eluser]robjstanley[/eluser]
Oh i see, then yes.

I just got frustrated and removed all CI sessions and now im using plain old PHP Sessions and the problem is still there! No $_SESSION can be found from the home page.

On clicking home another PHP Session is added voiding the other.

I have never in my life been so stumped when it comes to working with php.
#13

[eluser]toopay[/eluser]
Just do this simple test. Make some controller to display session data. And then, check if the session_id changed, if you instantly refresh the page.
#14

[eluser]robjstanley[/eluser]
The session works as it should until home is clicked, from there it seems another session is created out of thin air.
#15

[eluser]toopay[/eluser]
Did you mean, everything working fine except if you load specific controller?
#16

[eluser]robjstanley[/eluser]
Yes, the session is started in the login controller.

When the index function of the main view controller is loaded another session is created.
#17

[eluser]robjstanley[/eluser]
Ok i found something out

if i go to "www.site.com/" then the session is created
but if i go to "www.site.com/view/" then it isnt and the original session is created

obviously both urls load the index function of the view controller but with different results.
#18

[eluser]toopay[/eluser]
can you post how your controller looks like...
#19

[eluser]robjstanley[/eluser]
Login
Code:
class Login extends Controller {
    
    function __construct()
    {
        parent::Controller();
        session_start();
        //$this->logged_in();      
    }
    
    function index()
    {
         $data['content'] = 'login';
         $this->load->view('template',$data);        
    }
    
    function validate()
    {        
        $this->load->model('user_model');
        $id = $this->user_model->validate();
        
        if($id) // if the user's credentials validated...
        {
            $data = array(
                'user_id' => $id,
                'is_logged_in' => true
            );
            $_SESSION['user'] = $data;
            redirect('/panel');
        }
        else // incorrect username or password
        {
            $this->index();
        }
    }    
}

View
Code:
<?php

    class View extends Controller{
      
       function __construct()
        {
            parent::Controller();
            session_start();
            

       }
    
        function index()
        {
            $this->load->model('reviews_model');
            $this->load->model('news_model');
            $this->load->helper('img_helper');
                    
            $data['review'] = $this->reviews_model->latest();
            $data['recent'] = $this->reviews_model->recent();
            $data['news'] = $this->news_model->latest();
            
            $data['content'] = 'home';
            $this->load->view('template',$data);
        }
}
#20

[eluser]toopay[/eluser]
can you undo your change, to before you apply that native php session in your code, and then post it here? i want to see.




Theme © iAndrew 2016 - Forum software by © MyBB