libs/CookieDescriptor.php
public static function getFromHeaderLine($header_line, $source_url)
    {
        $parts = explode(';', trim($header_line));

        $name = '';
        $value = '';
        $expires = null;
        $path = null;
        $domain = '';

        // Name and value
        preg_match('#([^=]*)=(.*)#', $parts[0], $match);
        $name = trim($match[1]);
        $value = trim($match[2]);

        // Path and Expires
        for ($x = 1; $x < count($parts); ++$x) {
            $parts[$x] = trim($parts[$x]);

            if (preg_match("#^expires\s*=(.*)# i", $parts[$x], $match)) {
                $expires = trim($match[1]);
            }
            if (preg_match("#^path\s*=(.*)# i", $parts[$x], $match)) {
                $path = trim($match[1]);
            }
            if (preg_match("#^domain\s*=(.*)# i", $parts[$x], $match)) {
                $domain = trim($match[1]);
            }
        }

        $expires = str_replace('"', '', $expires);
        $path = str_replace('"', '', $path);
        $domain = str_replace('"', '', $domain);

        return new self($source_url, $name, $value, $expires, $path, $domain);
    }
public static function getFromHeaderLine($header_line, $source_url)
    {
        $parts = explode(';', trim($header_line));

        $name = '';
        $value = '';
        $expires = null;
        $path = null;
        $domain = '';

        // Name and value
        preg_match('#([^=]*)=(.*)#', $parts[0], $match);
        $name = trim($match[1]);
        $value = trim($match[2]);

        // Path and Expires
        for ($x = 1; $x < count($parts); ++$x) {
            $parts[$x] = trim($parts[$x]);

            if (preg_match("#^expires\s*=(.*)# i", $parts[$x], $match)) {
                $expires = trim($match[1]);
            }
            if (preg_match("#^path\s*=(.*)# i", $parts[$x], $match)) {
                $path = trim($match[1]);
            }
            if (preg_match("#^domain\s*=(.*)# i", $parts[$x], $match)) {
                $domain = trim($match[1]);
            }
        }

        $expires = str_replace('"', '', $expires);
        $path = str_replace('"', '', $path);
        $domain = str_replace('"', '', $domain);

        return new self($source_url, $name, $value, $expires, $path, $domain);
    }
public static function getFromHeaderLine ( $ header_line , $ source_url ) { $ parts = explode ( ';' , trim ( $ header_line ) ) ; $ name = '' ; $ value = '' ; $ expires = null ; $ path = null ; $ domain = '' ; // Name and value preg_match ( '#([^=]*)=(.*)#' , $ parts [ 0 ] , $ match ) ; $ name = trim ( $ match [ 1 ] ) ; $ value = trim ( $ match [ 2 ] ) ; // Path and Expires for ( $ x = 1 ; $ x < count ( $ parts ) ; ++ $ x ) { $ parts [ $ x ] = trim ( $ parts [ $ x ] ) ; if ( preg_match ( "#^expires\s*=(.*)# i" , $ parts [ $ x ] , $ match ) ) { $ expires = trim ( $ match [ 1 ] ) ; } if ( preg_match ( "#^path\s*=(.*)# i" , $ parts [ $ x ] , $ match ) ) { $ path = trim ( $ match [ 1 ] ) ; } if ( preg_match ( "#^domain\s*=(.*)# i" , $ parts [ $ x ] , $ match ) ) { $ domain = trim ( $ match [ 1 ] ) ; } } $ expires = str_replace ( '"' , '' , $ expires ) ; $ path = str_replace ( '"' , '' , $ path ) ; $ domain = str_replace ( '"' , '' , $ domain ) ; return new self ( $ source_url , $ name , $ value , $ expires , $ path , $ domain ) ; }
Returns a CookieDescriptor-object initiated by the given cookie-header-line.

@param string $header_line The line from an header defining the cookie, e.g. "VISITOR=4c63394c2d82e31552001a58; expires="Sat, 08-Aug-2020 23:59:08 GMT"; Path=/"
@param string $source_url  URL the cookie was send from.

@return CookieDescriptor The appropriate CookieDescriptor-object.
Returns a CookieDescriptor - object initiated by the given cookie - header - line .