san san - 7 months ago 101
PHP Question

Session conflict for frontend and backend logins - codeigniter

I have a site which has a front end and a backend section.
The problem is, when I login from the frontend section, and open the admin dashboard, I am logged in automatically, I dont want admin to login unless he enters the username and password.

I am using sessions.

How will I be able to fix that.. ? I am using codeigniter


With out seeing your code it bit hard but here is how I do front and back end


$segments = explode('/', $_SERVER['REQUEST_URI_PATH']);

$config['sess_driver'] = 'files';

if ($segments[2] == 'admin') {

    $config['sess_cookie_name'] = 'admin_sessions';
    $config['sess_expiration'] = 1440;
    $config['sess_save_path'] = FCPATH . 'application/cache/session/admin/';

} else {

    $config['sess_cookie_name'] = 'catalog_sessions';
    $config['sess_expiration'] = 7200;
    $config['sess_save_path'] = FCPATH . 'application/cache/session/catalog/';


$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE;

Another way to set

$data = array(
    'is_logged' => true,
    'user_id' => somenumber

$this->session->set_userdata('backend', $data);

$data1 = array(
    'is_logged' => true,
    'customer_id' => somenumber

$this->session->set_userdata('frontend', $data1);


$admin_session_data = $this->session->userdata('backend');

echo $admin_session_data['user_id'];

$frontend_session_data = $this->session->userdata('frontend');

echo $frontend_session_data['customer_id'];