* A better method might be to use a blacklist like
* http://publicsuffix.org/
*
+ * @fixme fails to detect 3-letter top-level domains
+ * @fixme fails to detect 2-letter top-level domains for single-domain use (probably not a big problem in practice, but there are test cases)
+ *
* @param $domain String: the domain to validate
* @param $originDomain String: (optional) the domain the cookie originates from
* @return Boolean
return $ret;
}
+ /**
+ * @param $domain
+ * @return bool
+ */
protected function canServeDomain( $domain ) {
if ( $domain == $this->domain
|| ( strlen( $domain ) > strlen( $this->domain )
return false;
}
+ /**
+ * @param $path
+ * @return bool
+ */
protected function canServePath( $path ) {
- if ( $this->path && substr_compare( $this->path, $path, 0, strlen( $this->path ) ) == 0 ) {
- return true;
- }
-
- return false;
+ return ( $this->path && substr_compare( $this->path, $path, 0, strlen( $this->path ) ) == 0 );
}
+ /**
+ * @return bool
+ */
protected function isUnExpired() {
- if ( $this->isSessionKey || $this->expires > time() ) {
- return true;
- }
-
- return false;
+ return $this->isSessionKey || $this->expires > time();
}
}
/**
* @see Cookie::serializeToHttpRequest
+ * @return string
*/
public function serializeToHttpRequest( $path, $domain ) {
$cookies = array();
*
* @param $cookie String
* @param $domain String: cookie's domain
+ * @return null
*/
public function parseCookieResponseHeader ( $cookie, $domain ) {
$len = strlen( 'Set-Cookie:' );