CodeIgniter Forums
Session express when I use ajax imap - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Session express when I use ajax imap (/showthread.php?tid=69604)



Session express when I use ajax imap - wolfgang1983 - 12-20-2017

Hello,

I use ajax to call some imap functions how ever the session tends to expire before the sess_expiration 7200 limit.

I am not sure if it is some thing to do with session_time_to_update?

Any suggestions what I should change?


PHP Code:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = BASEPATH 'cache/admin/session/';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE



RE: Session express when I use ajax imap - InsiteFX - 12-21-2017

The session expiration time.

There is also a CodeIgniter method for checking Ajax calls.

PHP Code:
if (is_ajax_request())
{
 
   // This is a Ajax Request
}
else
{
 
   // This is a Normal Request




RE: Session express when I use ajax imap - XtreemDeveloper - 12-23-2017

you can basically disable the session updates when AJAX calls are made. This code should go in /application/libraries/MY_Session.php
 <?php
class MY_Session extends CI_Session {

    /**
     * Update an existing session
     *
     * @access    public
     * @return    void
    */
    function sess_update() {
       // skip the session update if this is an AJAX call! This is a bug in CI; see:
       // https://github.com/EllisLab/CodeIgniter/issues/154
       // http://codeigniter.com/forums/viewthread/102456/P15
       if ( !($this->CI->input->is_ajax_request()) ) {
           parent:Confusedess_update();
       }
    }
}