Xenforo Sessions in external php files, IPv6 issues?

So I've been using this code to grab the user sessions for a long time, and it works great. However I've started getting user complaints of pages not working, and the only thing I can see different about the users with issues is they have IPv6 Addresses. Any Ideas?

        //Xenforo install location
        $fileDir = '/var/www/vhosts/public_html/forums';
        //Xenforo Session Setup
        require ($fileDir . '/library/XenForo/Autoloader.php');
        XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
        XenForo_Application::initialize($fileDir . '/library/', $fileDir);
        $request = new Zend_Controller_Request_Http();
        $session = XenForo_Session::startPublicSession($request);
        $userModel = XenForo_Model::create('XenForo_Model_User');
        $this->user = $userModel->getUserById($session->get('user_id'));
        $this->visitor = XenForo_Visitor::getInstance()->toArray();
        $this->custom_fields = unserialize($this->visitor['custom_fields']);
I think its has something to do with https. I was able to work around the problem by modifying the xenforo->helper->cookie.php

return self::_setCookieInternal($name, $value, $expiration, $httponly, $secure);

return self::_setCookieInternal($name, $value, $expiration, false, false);