我一直在使用ion_auth與笨的系統3年。突然之間的會議沒有按照他們應該做的那樣工作。Ion_auth - 在一個會話多個用戶
當用戶A登錄到網站,他們的會話似乎與所有其他用戶共享。因此,當用戶B導航到任何路由時,他們都會以用戶A的憑證「登錄」。
我已經用多個用戶測試了這一點,只要用戶登錄到網站,所有其他訪問該網站的用戶都會自動使用該用戶的憑證/會話登錄。
如果用戶註銷並且調用auth/logout路由,則會話不會被銷燬,所有用戶都會保持登錄該會話。
登錄後的初始重定向進入/車輛/索引。一旦你導航到任何其他頁面,檢查用戶是否登錄,你被重定向登錄。
主控制器代碼:
public function vehicle()
{
if (!$this->ion_auth->logged_in())
{
redirect('auth/login');
}
else {
if (!$this->ion_auth->is_admin()) {
/**
*
* User IS NOT admin
*
**/
// Get User_id if standard user
$user = $this->ion_auth->user()->row();
// Build Crud
控制器auth.php
public function logout()
{
$this->data['title'] = "Logout";
// log the user out
$logout = $this->ion_auth->logout();
// redirect them to the login page
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect('auth/login', 'refresh');
}
服務器PHP版本30年6月5日 - 生成日期2017年2月3日7時51分58秒
笨2.2版0.1 - 版本沒有改變
Ion_Auth配置:
$config['hash_method'] = 'bcrypt'; // sha1 or bcrypt, bcrypt is
STRONGLY recommended
$config['default_rounds'] = 8; // This does not apply if random_rounds is set to true
$config['random_rounds'] = FALSE;
$config['min_rounds'] = 5;
$config['max_rounds'] = 9;
$config['salt_prefix'] = version_compare(PHP_VERSION, '5.3.7', '<') ? '$2a$' : '$2y$';
/*
| -------------------------------------------------------------------------
| Authentication options.
| -------------------------------------------------------------------------
| maximum_login_attempts: This maximum is not enforced by the library, but is
| used by $this->ion_auth->is_max_login_attempts_exceeded().
| The controller should check this function and act
| appropriately. If this variable set to 0, there is no maximum.
*/
$config['site_title'] = "Cars in the park"; // Site Title, example.com
$config['admin_email'] = "[email protected]"; // Admin Email, [email protected]
$config['default_group'] = 'members'; // Default group, use name
$config['admin_group'] = 'admin'; // Default administrators group, use name
$config['identity'] = 'email'; // A database column which is used to login with
$config['min_password_length'] = 8; // Minimum Required Length of Password
$config['max_password_length'] = 20; // Maximum Allowed Length of Password
$config['email_activation'] = TRUE; // Email Activation for registration
$config['manual_activation'] = TRUE; // Manual Activation for registration
$config['remember_users'] = FALSE; // Allow users to be remembered and enable auto-login
$config['user_expire'] = 30; // How long to remember the user (seconds). Set to zero for no expiration
$config['user_extend_on_login'] = FALSE; // Extend the users cookies every time they auto-login
$config['track_login_attempts'] = TRUE; // Track the number of failed login attempts for each user or ip.
$config['track_login_ip_address'] = TRUE; // Track login attempts by IP Address, if FALSE will track based on identity. (Default: TRUE)
$config['maximum_login_attempts'] = 3; // The maximum number of failed login attempts.
$config['lockout_time'] = 600; // The number of seconds to lockout an account due to exceeded attempts
$config['forgot_password_expiration'] = 0; // The number of milliseconds after which a forgot password request will expire. If set to 0, forgot password requests will not expire.
會話配置:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 30;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = FALSE;
$config['sess_time_to_update'] = 30;
會話變量(登錄的用戶。所有其他用戶在會話中的相同信息):
stdClass Object ([id] => 1148 [ip_address] => [username] => testing [password] => $2y$08$Q4fjUfsuOKM/Q8cnQt6j0uSXP.3mCqMnzDY1nBA9RDlwm [salt] => sadsda [email] => [email protected] [activation_code] => [forgotten_password_code] => [forgotten_password_time] => [remember_code] => [created_on] => 1426181328 [last_login] => 1490008619 [active] => 1 [first_name] => Name [last_name] => Testing [company] => [phone] => [user_id] => 1148)
您是否執行CI升級,是否在您的服務器上升級了php?請檢查所有可能的配置更改並將其編輯爲您的問題。謝謝 – Vickel
如果它曾經工作過,並且你沒有編輯代碼,那麼你描述的是不可能的......儘管已經正確安裝了Ion Auth,共享相同會話的兩個用戶已經不太可能了。檢查文件修改日期以驗證沒有人篡改任何內容。另外,我對你如何測試這個問題非常懷疑......你是否使用不同的機器和/或瀏覽器來驗證這些觀察結果? – Sparky
我在不同的設備上測試了這一點,不同的連接和結果保持不變。一個會話被創建並且每個人都停留在那個會話上直到它到期。註銷不會銷燬會話,但logged_in()返回false,所以所有頁面在第一次重定向後重定向回登錄。 –