protected function addSession($uid, $remember)
    {
        $ip = $this->getIp();
        $user = $this->getBaseUser($uid);

        if (!$user) {
            return false;
        }

        $data['hash'] = sha1($this->config->site_key . microtime());
        $agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';

        if (!$this->config->allow_concurrent_sessions) {
            $this->deleteExistingSessions($uid);
        }

        if ($remember == true) {
            $data['expire'] = strtotime($this->config->cookie_remember);
        } else {
            $data['expire'] = strtotime($this->config->cookie_forget);
        }

        $data['cookie_crc'] = sha1($data['hash'] . $this->config->site_key);

        // don't use INET_ATON(:ip), use ip2long(), 'cause SQLite or PosgreSQL does not have INET_ATON() function
        $query = "
INSERT INTO {$this->config->table_sessions}
(uid, hash, expiredate, ip, agent, cookie_crc)
VALUES (:uid, :hash, :expiredate, :ip, :agent, :cookie_crc)
";
        $query_prepared = $this->dbh->prepare($query);
        $query_params = [
            'uid'       => $uid,
            'hash'      => $data['hash'],
            'expiredate'=> date("Y-m-d H:i:s", $data['expire']),
            'ip'        => $ip,
            'agent'     => $agent,
            'cookie_crc'=> $data['cookie_crc']
        ];

        if (!$query_prepared->execute($query_params)) {
            return false;
        }

        setcookie($this->config->cookie_name, $data['hash'], $data['expire'], $this->config->cookie_path, $this->config->cookie_domain, $this->config->cookie_secure, $this->config->cookie_http);
        $_COOKIE[$this->config->cookie_name] = $data['hash'];

        return $data;
    }
protected function addSession($uid, $remember)
    {
        $ip = $this->getIp();
        $user = $this->getBaseUser($uid);

        if (!$user) {
            return false;
        }

        $data['hash'] = sha1($this->config->site_key . microtime());
        $agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';

        if (!$this->config->allow_concurrent_sessions) {
            $this->deleteExistingSessions($uid);
        }

        if ($remember == true) {
            $data['expire'] = strtotime($this->config->cookie_remember);
        } else {
            $data['expire'] = strtotime($this->config->cookie_forget);
        }

        $data['cookie_crc'] = sha1($data['hash'] . $this->config->site_key);

        // don't use INET_ATON(:ip), use ip2long(), 'cause SQLite or PosgreSQL does not have INET_ATON() function
        $query = "
INSERT INTO {$this->config->table_sessions}
(uid, hash, expiredate, ip, agent, cookie_crc)
VALUES (:uid, :hash, :expiredate, :ip, :agent, :cookie_crc)
";
        $query_prepared = $this->dbh->prepare($query);
        $query_params = [
            'uid'       => $uid,
            'hash'      => $data['hash'],
            'expiredate'=> date("Y-m-d H:i:s", $data['expire']),
            'ip'        => $ip,
            'agent'     => $agent,
            'cookie_crc'=> $data['cookie_crc']
        ];

        if (!$query_prepared->execute($query_params)) {
            return false;
        }

        setcookie($this->config->cookie_name, $data['hash'], $data['expire'], $this->config->cookie_path, $this->config->cookie_domain, $this->config->cookie_secure, $this->config->cookie_http);
        $_COOKIE[$this->config->cookie_name] = $data['hash'];

        return $data;
    }
protected function addSession ( $ uid , $ remember ) { $ ip = $ this -> getIp ( ) ; $ user = $ this -> getBaseUser ( $ uid ) ; if ( ! $ user ) { return false ; } $ data [ 'hash' ] = sha1 ( $ this -> config -> site_key . microtime ( ) ) ; $ agent = isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ? $ _SERVER [ 'HTTP_USER_AGENT' ] : '' ; if ( ! $ this -> config -> allow_concurrent_sessions ) { $ this -> deleteExistingSessions ( $ uid ) ; } if ( $ remember == true ) { $ data [ 'expire' ] = strtotime ( $ this -> config -> cookie_remember ) ; } else { $ data [ 'expire' ] = strtotime ( $ this -> config -> cookie_forget ) ; } $ data [ 'cookie_crc' ] = sha1 ( $ data [ 'hash' ] . $ this -> config -> site_key ) ; // don't use INET_ATON(:ip), use ip2long(), 'cause SQLite or PosgreSQL does not have INET_ATON() function $ query = "
INSERT INTO {$this->config->table_sessions}
(uid, hash, expiredate, ip, agent, cookie_crc)
VALUES (:uid, :hash, :expiredate, :ip, :agent, :cookie_crc)
" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; $ query_params = [ 'uid' => $ uid , 'hash' => $ data [ 'hash' ] , 'expiredate' => date ( "Y-m-d H:i:s" , $ data [ 'expire' ] ) , 'ip' => $ ip , 'agent' => $ agent , 'cookie_crc' => $ data [ 'cookie_crc' ] ] ; if ( ! $ query_prepared -> execute ( $ query_params ) ) { return false ; } setcookie ( $ this -> config -> cookie_name , $ data [ 'hash' ] , $ data [ 'expire' ] , $ this -> config -> cookie_path , $ this -> config -> cookie_domain , $ this -> config -> cookie_secure , $ this -> config -> cookie_http ) ; $ _COOKIE [ $ this -> config -> cookie_name ] = $ data [ 'hash' ] ; return $ data ; }
Creates a session for a specified user id
@param int $uid
@param boolean $remember
@return array $data
Creates a session for a specified user id