0

I am using Tank Auth for user authentication. I am using the database to store sessions and using $this->auth->tank_auth->is_logged_in() to check if user is logged in. HMVC is also used, where auth module contains tank_auth.

Problem: It seems that some browsers cannot successfully log in into the website, including IE8, Chrome 15.0.874.121. Earlier versions of Chrome and IE are able to login. I did a trace of redirects and found out that upon logging in, the user is redirected to the main page, where the check is_logged_in() fails and redirects the user back to the login back. Anyone knows the problem?

Config.php

$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

CI Controller Code

function index() {
    $this->load->module('auth');
    if(!$this->auth->tank_auth->is_logged_in()) {
         redirect('login');
    } 

    $this->load->view('main');

}
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
  • Use the respective developer tool extensions and debug the session cookies. – mario Dec 09 '11 at 19:55
  • The cookies does not seem to be stored on the Chrome that was not able to login. I do see the cookie on the Chrome that logged in successfully. Seems like the cookie cant be set on the Chrome that didnt work? I see other websites' cookies on the Chrome that didnt sign in successfully – Nyxynyx Dec 09 '11 at 20:03

2 Answers2

4

I have seen problems with this before where it only works in some browsers. I can not find the link but I read somewhere that it is the varchar size of useragent in DB that causes the problem. The solution was to make it larger.

Maybe this will help

http://codeigniter.com/forums/viewthread/197101/

shezzy
  • 56
  • 2
  • You deserve a vote for that. Shame on people who post questions with obscure answers, get bailed out by people like you, and then just moving on with their day without a simple upvote. – tpow Jan 31 '12 at 13:47
2

Another caveat is the time difference between the server and the client. Either synchronize the time between server and client or check the "remember me" checkbox

Morris
  • 169
  • 8