1

I am using Codeigniter for an application and added Tank_Auth as Authentication system.

Locally (XAMPP) things work perfectly (login, logout). On a server though I noticed a bug, when I login , I go through, when I logout, I am redirected to the login page, when I do the same thing right away I login , I am in , I logout .. I am still in, the logout is not working anymore.

I am wondering if this is a cookie/session issue.

my logout function is like this :

function logout()
    {
        $this->db->cache_delete_all();
        $this->tank_auth->logout();
        $this->session->sess_create();

         //$this->_show_message($this->lang->line('auth_message_logged_out'));
                redirect('/auth/login/','refresh');

        //$this->_show_message($this->lang->line('auth_message_logged_out'));

    }

the only difference between the server verison and the local version is the .htaccess, I am wondering if this has anything to do with that

My htaccess is

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 week"
ExpiresByType image/jpeg "access 1 week"
ExpiresByType image/gif "access 1 week"
ExpiresByType image/png "access 1 week"
ExpiresByType text/css "access 1 week"
ExpiresByType application/pdf "access 1 week"
ExpiresByType text/x-javascript "access 1 week"
ExpiresByType application/x-shockwave-flash "access 1 week"
ExpiresByType image/x-icon "access 1 week"
ExpiresDefault "access plus 1 year"
</IfModule>

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

DirectoryIndex index.php
RewriteEngine on
RewriteBase /app/
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA] 
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/javascript

Any idea ?

Thanks

EDIT : Problem Solved

This was causing the session logout problem ExpiresDefault "access plus 1 year" After removing this line the authentication worked like a charm

Rad
  • 989
  • 3
  • 14
  • 31

1 Answers1

2

Try something like this:

function logout()
{
    $this->delete_autologin();
    $this->tank_auth->logout();
    // See http://codeigniter.com/forums/viewreply/662369/ as the reason for the next line
    $this->ci->session->set_userdata(array('user_id' => '', 'username' => '', 'status' => ''));


        $this->ci->session->sess_destroy();
}

N.B:If your hosting provider has mod_gzip module disabled then remove mod_gzip portion from .htaccess

Suvash sarker
  • 3,140
  • 1
  • 18
  • 21
  • Tried this solution, still same behaviour (cache cleared and browser restarted) – Rad Nov 25 '13 at 16:57
  • I removed the mod_gzip part of htaccess and it worked perfectly, what's in this section that can cause that behavior ? – Rad Nov 25 '13 at 17:13
  • 1
    mod_gzip is an external extension module for Apache that allows you to quickly and easily compress your files before you send them to the client. This speeds up your site like crazy and your hosting provider has mod_gzip module disabled that's why it was causing problem – Suvash sarker Nov 25 '13 at 17:35
  • take a look here http://www.samaxes.com/2008/04/htaccess-gzip-and-cache-your-site-for-faster-loading-and-bandwidth-saving/ – Suvash sarker Nov 25 '13 at 17:44
  • Actually it is this line ExpiresDefault "access plus 1 year" that caused the problem, the problem is fixed now, it was not the compression part of the htaccess – Rad Nov 25 '13 at 18:01