我Codeigniter
一切開發的一個應用是完全準備,但我有一個問題如下:
我想要實現autologin
兩個前端和背部首次登錄後到儀表板結束。
說明:
當我第一次去admin dashboard
和關閉tab/browser
沒有點擊logout button
登錄admin side
,並再次把admin
鏈接它去管理儀表板沒有登錄,高達這裏一切都很順利,但當我把front end link (after first time login and closing tab)
它不走的admin
儀表盤和節目,如笨的Cookie問題的後端和前端側
錯誤的頁面不重定向正確
我在前端面臨同樣的問題。
我想這樣做,因爲它是客戶的要求。
請幫我解決這個問題。謝謝。
這裏是我的索引功能
if($_COOKIE['AS_AD_SES_ADMIN_ID']!='' && $_COOKIE['stay_signedin']=='1')
{
$username = $_COOKIE['ADMIN_USERNAME'];
$password = $_COOKIE['ADMIN_PASS'];
$result = $this->verifylogin->login($username, $password);
foreach($result as $row)
{
$sess_array = array(
'AS_AD_SES_ADMIN_ID' => $row->fld_id,
'AS_AD_SES_ADMIN_FULL_NAME' => $row->fld_user_name,
'AS_AD_SES_ADMIN_NAME' => $row->fld_adm_name,
'AS_AD_SES_LOGIN_TIME' => date('h:i:s A'),
'AS_AD_SES_LOGIN_DATE' => date("d-m-Y"),
'AS_SES_ACCESS_LEVEL' => $row->fld_access_level,
'AS_TAB_TITLE' => 'Welcome to Project',
'logged_in' => TRUE
);
$this->session->set_userdata($sess_array);
}
$this->load->view('dashboard');
}else{
redirect(base_url());
}
Verifylogin車型登錄功能如下
function login($username, $password)
{
$ip_address=$_SERVER['REMOTE_ADDR'];
$this -> db -> select('fld_id, fld_user_name,fld_adm_name,fld_adm_pwd,fld_access_level');
$this -> db -> from('tbl_admin');
$this -> db -> where('fld_user_name',$username);
$query = $this -> db -> get();
if($query -> num_rows() == 1)
{
$res = $query->row();
$pass = $res->fld_adm_pwd;
$pass1 = $this->encrypt->decode($pass);
if($pass1 == $password)
{
$password = $pass;
$query = $this->db->query("SELECT fld_id,fld_user_name,fld_adm_name,fld_access_level,fld_adm_pwd,fld_stay_signed_in FROM tbl_admin where fld_user_name = '".$username."' and fld_adm_pwd = '".trim($password)."' and fld_isdeleted !=1 and fld_status = 'Active'");
if($query->num_rows() == 1)
{
return $query->result();
}
}
else
{
return false;
}
}
}
你的代碼在哪裏? – Saty
@saty感謝您的即時回覆,我在管理員登錄時使用了cookie,然後爲它設置了cookie。 –
我們不能幫助你,直到我們無法看到你的代碼? – Saty