Welcome Guest, Not a member yet? Register   Sign In
two secure account areas
#1

[eluser]pdxbenjamin[/eluser]
I followed a tutorial somewhere that had me create a login and account area by setting a
" is_logged_in " variable. I used this for users.
However now my project has called for a second "admin" area and the is_logged_in is causing some problems. When I am logged in as a user I can access my admin area.

Is there a way to have a second account area, is_logged_in_users and is_logged_in_admin ?
#2

[eluser]frist44[/eluser]
There certainly is. How are you setting your "is_logged_in" variable? Is it session? If you store it in session, how are you setting it? Database?

Personally, i have a flag in my users table in the database that reads in whether the user is an admin or not. When the user logs in, that flag is read and stored in the session data. When the /admin area is accessed, it accepts/denies based on whether the user has a username in session (logged in) and has the admin flag in session.

So it all depends on how you are doing thing, but the same concept applies.
#3

[eluser]pdxbenjamin[/eluser]
$this->load->model('admin_model');
$data['logon'] = $this->admin_model->user_validate($user_id, $password);

if($data['logon'] == 1)
{
$data = array(
'membership' => $this->input->post('user_id'),
'is_logged_in_admin' => true
);
$this->session->set_userdata($data);
redirect('secure');

} else {

redirect('admin');

}

Set through sessions...

While I was typing out my question that solution came to mind however, admins and users have different data and I usually like to make more tables then have one big table sparsely filled.

I already have user permission levels and admin permission levels it wouldn't be too much to combine them....

But I was hoping to find out that the is_logged_in is just a crazy codeigniter constant that I could modify or make more of...




Theme © iAndrew 2016 - Forum software by © MyBB