0

Hi guys having a bit of a problem with setting userdata to true, maybe someone on here can help me out?

I am using codeigniter

here is my controller where I set the userdata and redirect forward to another controller "site" and call the function members_area

    if($query) // if the users pass/user is right
    {
        $data = array(
        'username' => $this->input->post('username'),
        'is_logged_in' => true      
        );
        $this->session->set_userdata($data);
        redirect('site/members_area');
    }
    else{
    $this->index(); 

    }

Then this is my site controller:

function __construct(){

    parent::__construct();
    $this->is_logged_in();
}

function members_area()
{

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

function is_logged_in()
{
    $is_logged_in = $this->session->userdata('is_logged_in');

    if(!isset($is_logged_in) ||  $is_logged_in != true)
    {
        echo 'You don\'t have permission to access this page. <a href="../login">Login</a>';
        die();

    }

}

What do you guys reckon? Much appreciated!

4
  • so what happend ? please tell in details Commented Aug 3, 2012 at 12:50
  • It still says I dont have permission after sucecssfully logging in and being redirected to the members_area Commented Aug 3, 2012 at 13:34
  • Have you added $this->load->library('session'); in your site controller anywhere (preferably constructor) ? Commented Aug 3, 2012 at 14:36
  • I am autoloading session in the config, although have tried loading it your way aswell and still the same Commented Aug 3, 2012 at 15:03

1 Answer 1

1

Fixed it by setting $config['cookie_secure'] = FALSE; in the autoload.php in config folder, as it was TRUE before to secure cookies, any insight on why might be great? but this fixed the problem :)

Sign up to request clarification or add additional context in comments.

1 Comment

If its set to true, cookies will only be set if a secure connection exists i.e. when your website is running on HTTPS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.