38 $this->
set(
$value, $attr );
53 public function set(
$value, $attr ) {
56 if ( isset( $attr[
'expires'] ) ) {
57 $this->isSessionKey =
false;
58 $this->expires = strtotime( $attr[
'expires'] );
61 $this->path = $attr[
'path'] ??
'/';
63 if ( isset( $attr[
'domain'] ) ) {
64 if ( self::validateCookieDomain( $attr[
'domain'] ) ) {
65 $this->domain = $attr[
'domain'];
68 throw new InvalidArgumentException(
'$attr must contain a domain' );
92 if ( substr(
$domain, -1 ) ==
'.' ||
94 count( $dc ) == 2 && $dc[0] ===
''
100 if ( preg_match(
'/^[0-9.]+$/',
$domain ) ) {
101 if ( count( $dc ) != 4 ) {
105 if ( ip2long(
$domain ) ===
false ) {
109 if ( $originDomain ==
null || $originDomain ==
$domain ) {
117 if ( ( count( $dc ) == 2 && strlen( $dc[0] ) <= 2 )
118 || ( count( $dc ) == 3 && strlen( $dc[0] ) ==
"" && strlen( $dc[1] ) <= 2 ) ) {
121 if ( ( count( $dc ) == 2 || ( count( $dc ) == 3 && $dc[0] ==
'' ) )
122 && preg_match(
'/(com|net|org|gov|edu)\...$/',
$domain ) ) {
127 if ( $originDomain !=
null ) {
128 if ( substr(
$domain, 0, 1 ) !=
'.' &&
$domain != $originDomain ) {
132 if ( substr(
$domain, 0, 1 ) ==
'.'
173 || ( strlen(
$domain ) > strlen( $this->domain )
174 && substr( $this->domain, 0, 1 ) ==
'.'
178 -strlen( $this->domain ),
179 strlen( $this->domain ),
195 return ( $this->path && substr_compare( $this->path,
$path, 0, strlen( $this->path ) ) == 0 );
202 return $this->isSessionKey || $this->expires > time();