CakePHP session and cache handling

74 Views Asked by At

If there are login issues associated with a CakePHP application, is there something specific that one should be looking at ? I understand the permissions should be correctly configured on the tmp directory inside the application directory. The session file is created under /app/tmp/sessions but the user is still not logged in. And this seems to be very inconsistent i.e., I can or cannot login as the same user from two different browsers, can login from one browser but cannot login from the other. There isn't a specific pattern at all.

Secondly, every time the latest build is deployed, the application still renders the old cached data. This is inspite of clearing the app/tmp/cache directory. As a workaround, I toggle the debug mode in core.php which seems to clear the cache.

Could someone with the knowhow suggest what is the best way to debug the issue, please ?

Thank you

Below is the code for cache and session handling. I tried changing the session defaults to 'php' from 'cake' and since then its working fine. But I'm not sure if this can have unforeseen consequences. So, I would still like to preserve the old code for session handling.

 /**
 * Configure the cache used for general framework caching. Path information,
 * object listings, and translation cache files are stored with this configuration.
 */
Cache::config('_cake_core_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_core_',
'path' => CACHE . 'persistent' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration
));

 /**
 * Configure the cache for model and datasource caches. This cache configuration
 * is used to store schema descriptions, and table listings in connections.
 */

Cache::config('_cake_model_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_model_',
'path' => CACHE . 'models' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration
));


Configure::write('Session', array(
    'defaults' => 'cake',
    'timeout' => 86400, // The session will timeout after 2 hours of inactivity
    'cookieTimeout' => 86400, // The session cookie will live for at most 24 hours, this does not effect session timeouts
    'checkAgent' => false,
    'autoRegenerate' => true,  // causes the session expiration time to reset on each page load
));


Configure::write('Session', array(
    'defaults' => 'cake',
    'timeout' => 86400,
    'ini' => array(
        'session.cookie_path' => str_replace(str_replace(DS, '/', str_replace(ROOT, '', WWW_ROOT).'index.php'), '', $_SERVER['SCRIPT_NAME'])
    )
));

The above session handling part has been changed to the below and since then its been fine.

Configure::write('Session', array(
    'defaults' => 'php',
    'timeout' => 86400, // The session will timeout after 2 hours of inactivity
    'cookieTimeout' => 86400, // The session cookie will live for at most 24 hours, this does not effect session timeouts
    'checkAgent' => false,
    'autoRegenerate' => true,  // causes the session expiration time to reset on each page load
));
0

There are 0 best solutions below