Welcome Guest, Not a member yet? Register   Sign In
CI 3 Session Lock Ajax
#1

Hi, From this thread https://forum.codeigniter.com/thread-70845.html , I upgraded CI 2 to CI 3.1.8 and problem was solved. But I got new problem with multi ajax request. 
Example : When user switch between 2 pages. Ajax request of 1st page must be completed, then user can change to 2nd page. User can't go to 2nd page or other page i ajax request of 1st page isn't complete. (User can't wait until All ajax of 1st page complete  Sad ).

I'm using database for session storage driver. I found codes in Session_database_driver.php, these codes seem lock ajax request: 

PHP Code:
/**
     * Get lock
     *
     * Acquires a lock, depending on the underlying platform.
     *
     * @param    string    $session_id    Session ID
     * @return    bool
     */
    
protected function _get_lock($session_id)
    {
        if (
$this->_platform === 'mysql')
        {
            
$arg md5($session_id.($this->_config['match_ip'] ? '_'.$_SERVER['REMOTE_ADDR'] : ''));
            if (
$this->_db->query("SELECT GET_LOCK('".$arg."', 300) AS ci_session_lock")->row()->ci_session_lock)
            {
                
$this->_lock $arg;
                return 
TRUE;
            }

            return 
FALSE;
        }
        elseif (
$this->_platform === 'postgre')
        {
            
$arg "hashtext('".$session_id."')".($this->_config['match_ip'] ? ", hashtext('".$_SERVER['REMOTE_ADDR']."')" '');
            if (
$this->_db->simple_query('SELECT pg_advisory_lock('.$arg.')'))
            {
                
$this->_lock $arg;
                return 
TRUE;
            }

            return 
FALSE;
        }

        return 
parent::_get_lock($session_id);
    }

    
// ------------------------------------------------------------------------

    /**
     * Release lock
     *
     * Releases a previously acquired lock
     *
     * @return    bool
     */
    
protected function _release_lock()
    {
        if ( ! 
$this->_lock)
        {
            return 
TRUE;
        }

        if (
$this->_platform === 'mysql')
        {
            if (
$this->_db->query("SELECT RELEASE_LOCK('".$this->_lock."') AS ci_session_lock")->row()->ci_session_lock)
            {
                
$this->_lock FALSE;
                return 
TRUE;
            }

            return 
FALSE;
        }
        elseif (
$this->_platform === 'postgre')
        {
            if (
$this->_db->simple_query('SELECT pg_advisory_unlock('.$this->_lock.')'))
            {
                
$this->_lock FALSE;
                return 
TRUE;
            }

            return 
FALSE;
        }

        return 
parent::_release_lock();
    } 

Is there any config to affect above code ? I wan't to abort all ajax request when user switch the pages, My project have many features with multi ajax  Sad .


Thanks in advance .
Reply


Messages In This Thread
CI 3 Session Lock Ajax - by yoyovolam - 06-12-2018, 05:37 AM
RE: CI 3 Session Lock Ajax - by InsiteFX - 06-12-2018, 09:26 AM
RE: CI 3 Session Lock Ajax - by dave friend - 06-12-2018, 12:06 PM
RE: CI 3 Session Lock Ajax - by Paradinight - 06-12-2018, 08:30 PM
RE: CI 3 Session Lock Ajax - by Pertti - 06-19-2018, 01:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB