Zend_Http_Client::getCookieJar PHP Method

getCookieJar() public method

Return the current cookie jar or null if none.
public getCookieJar ( ) : Zend_Http_CookieJar | null
return Zend_Http_CookieJar | null
    public function getCookieJar()
    {
        return $this->cookiejar;
    }

Usage Example

Exemplo n.º 1
0
 public static function login($request)
 {
     $blogPath = SJB_Settings::getSettingByName('blog_path');
     if (empty($blogPath)) {
         return;
     }
     $username = $request['username'];
     $password = $request['password'];
     $userInfo = SJB_UserManager::getUserInfoByUserName($username);
     $userInfo = $userInfo ? base64_encode(serialize($userInfo)) : false;
     $url = SJB_System::getSystemSettings('SITE_URL') . $blogPath . '/wp-login.php';
     $client = new Zend_Http_Client($url, array('useragent' => SJB_Request::getUserAgent(), 'maxredirects' => 0));
     $client->setCookieJar();
     $client->setCookie($_COOKIE);
     $client->setMethod(Zend_Http_Client::POST);
     $client->setParameterPost(array('log' => $username, 'pwd' => $password, 'noSJB' => 1, 'userInfo' => $userInfo, 'wp-submit' => 'Log in'));
     try {
         $response = $client->request();
         foreach ($response->getHeaders() as $key => $header) {
             if ('set-cookie' == strtolower($key)) {
                 if (is_array($header)) {
                     foreach ($header as $val) {
                         header("Set-Cookie: " . $val, false);
                     }
                 } else {
                     header("Set-Cookie: " . $header, false);
                 }
             }
         }
         $_SESSION['wp_cookie_jar'] = @serialize($client->getCookieJar());
     } catch (Exception $ex) {
     }
 }
All Usage Examples Of Zend_Http_Client::getCookieJar