Welcome Guest, Not a member yet? Register   Sign In
Flashdata and userdata in one function
#6

[eluser]beemr[/eluser]
Your "logged as" echo comes before any methods are called and therefore before any sessions can be set. Sessions need to be first in the return sequence.

Instead of affirming the "logged_in" session in your constructor, just test for its falsehood and redirect, then move your echo behind the session calls of each controller. Or better yet:
Code:
function __construct()
    {
        parent::Controller();
        $user_table = 'testusers';
        if ($this->session->userdata('logged_in'))
        {
            $data['logged_as'] = 'Logged as'.$this->session->userdata('username');
        }
        else
        {
            $data['logged_as'] = '';
            redirect('welcome/login','refresh');
        }
    }
and then make sure that you echo $logged_as in your view file.


Messages In This Thread
Flashdata and userdata in one function - by El Forum - 10-29-2008, 01:24 PM
Flashdata and userdata in one function - by El Forum - 10-29-2008, 01:37 PM
Flashdata and userdata in one function - by El Forum - 10-29-2008, 01:49 PM
Flashdata and userdata in one function - by El Forum - 10-29-2008, 02:01 PM
Flashdata and userdata in one function - by El Forum - 10-29-2008, 02:23 PM
Flashdata and userdata in one function - by El Forum - 10-29-2008, 03:32 PM
Flashdata and userdata in one function - by El Forum - 10-29-2008, 08:30 PM
Flashdata and userdata in one function - by El Forum - 10-30-2008, 10:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB