CookieTest.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Http_Cookie
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. require_once 'Zend/Http/Cookie.php';
  23. /**
  24. * Zend_Http_Cookie unit tests
  25. *
  26. * @category Zend
  27. * @package Zend_Http_Cookie
  28. * @subpackage UnitTests
  29. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. * @group Zend_Http
  32. * @group Zend_Http_Cookie
  33. */
  34. class Zend_Http_CookieTest extends PHPUnit_Framework_TestCase
  35. {
  36. /**
  37. * Cookie creation and data accessors tests
  38. */
  39. /**
  40. * Make sure we can't set invalid names
  41. *
  42. * @dataProvider invalidCookieNameCharProvider
  43. * @expectedException Zend_Http_Exception
  44. */
  45. public function testSetInvalidName($char)
  46. {
  47. $cookie = new Zend_Http_Cookie("cookie_$char", 'foo', 'example.com');
  48. }
  49. /**
  50. * Test we get the cookie name properly
  51. *
  52. * @dataProvider validCookieWithInfoProvider
  53. */
  54. public function testGetName($cStr, $cInfo)
  55. {
  56. $cookie = Zend_Http_Cookie::fromString($cStr);
  57. if (! $cookie instanceof Zend_Http_Cookie) {
  58. $this->fail("Failed creating a cookie object from '$cStr'");
  59. }
  60. if (isset($cInfo['name'])) {
  61. $this->assertEquals($cInfo['name'], $cookie->getName());
  62. }
  63. }
  64. /**
  65. * Make sure we get the correct value if it was set through the constructor
  66. *
  67. * @param string $value
  68. * @dataProvider validCookieValueProvider
  69. */
  70. public function testGetValueConstructor($val)
  71. {
  72. $cookie = new Zend_Http_Cookie('cookie', $val, 'example.com', time(), '/', true);
  73. $this->assertEquals($val, $cookie->getValue());
  74. }
  75. /**
  76. * Make sure we get the correct value if it was set through fromString()
  77. *
  78. * @param string $value
  79. * @dataProvider validCookieValueProvider
  80. */
  81. public function testGetValueFromString($val)
  82. {
  83. $cookie = Zend_Http_Cookie::fromString('cookie=' . urlencode($val) . '; domain=example.com');
  84. $this->assertEquals($val, $cookie->getValue());
  85. }
  86. /**
  87. * Make sure we get the correct value if it was set through fromString()
  88. *
  89. * @param string $value
  90. * @dataProvider validCookieValueProvider
  91. */
  92. public function testGetRawValueFromString($val)
  93. {
  94. // Because ';' has special meaning in the cookie, strip it out for this test.
  95. $val = str_replace(';', '', $val);
  96. $cookie = Zend_Http_Cookie::fromString('cookie=' . $val . '; domain=example.com', null, false);
  97. $this->assertEquals($val, $cookie->getValue());
  98. }
  99. /**
  100. * Make sure we get the correct value if it was set through fromString()
  101. *
  102. * @param string $value
  103. * @dataProvider validCookieValueProvider
  104. */
  105. public function testGetRawValueFromStringToString($val)
  106. {
  107. // Because ';' has special meaning in the cookie, strip it out for this test.
  108. $val = str_replace(';', '', $val);
  109. $cookie = Zend_Http_Cookie::fromString('cookie=' . $val . '; domain=example.com', null, false);
  110. $this->assertEquals('cookie=' . $val . ';', (string)$cookie);
  111. }
  112. /**
  113. * Make sure we get the correct value if it was set through fromString()
  114. *
  115. * @param string $value
  116. * @dataProvider validCookieValueProvider
  117. */
  118. public function testGetValueFromStringEncodedToString($val)
  119. {
  120. // Because ';' has special meaning in the cookie, strip it out for this test.
  121. $val = str_replace(';', '', $val);
  122. $cookie = Zend_Http_Cookie::fromString('cookie=' . $val . '; domain=example.com', null, true);
  123. $this->assertEquals('cookie=' . urlencode($val) . ';', (string)$cookie);
  124. }
  125. /**
  126. * Make sure we get the correct domain when it's set in the cookie string
  127. *
  128. * @dataProvider validCookieWithInfoProvider
  129. */
  130. public function testGetDomainInStr($cStr, $cInfo)
  131. {
  132. $cookie = Zend_Http_Cookie::fromString($cStr);
  133. if (! $cookie instanceof Zend_Http_Cookie) {
  134. $this->fail("Failed creating a cookie object from '$cStr'");
  135. }
  136. if (isset($cInfo['domain'])) {
  137. $this->assertEquals($cInfo['domain'], $cookie->getDomain());
  138. }
  139. }
  140. /**
  141. * Make sure we get the correct domain when it's set in a reference URL
  142. *
  143. * @dataProvider refUrlProvider
  144. */
  145. public function testGetDomainInRefUrl(Zend_Uri $uri)
  146. {
  147. $domain = $uri->getHost();
  148. $cookie = Zend_Http_Cookie::fromString('foo=baz; path=/', 'http://' . $domain);
  149. if (! $cookie instanceof Zend_Http_Cookie) {
  150. $this->fail("Failed creating a cookie object with URL '$uri'");
  151. }
  152. $this->assertEquals($domain, $cookie->getDomain());
  153. }
  154. /**
  155. * Make sure we get the correct path when it's set in the cookie string
  156. *
  157. * @dataProvider validCookieWithInfoProvider
  158. */
  159. public function testGetPathInStr($cStr, $cInfo)
  160. {
  161. $cookie = Zend_Http_Cookie::fromString($cStr);
  162. if (! $cookie instanceof Zend_Http_Cookie) {
  163. $this->fail("Failed creating a cookie object from '$cStr'");
  164. }
  165. if (isset($cInfo['path'])) {
  166. $this->assertEquals($cInfo['path'], $cookie->getPath());
  167. }
  168. }
  169. /**
  170. * Make sure we get the correct path when it's set a reference URL
  171. *
  172. * @dataProvider refUrlProvider
  173. */
  174. public function testGetPathInRefUrl(Zend_Uri $uri)
  175. {
  176. $path = $uri->getPath();
  177. if (substr($path, -1, 1) == '/') $path .= 'x';
  178. $path = dirname($path);
  179. if ($path == DIRECTORY_SEPARATOR) {
  180. $path = '/';
  181. }
  182. $cookie = Zend_Http_Cookie::fromString('foo=bar', (string) $uri);
  183. if (! $cookie instanceof Zend_Http_Cookie) {
  184. $this->fail("Failed creating a cookie object with URL '$uri'");
  185. }
  186. $this->assertEquals($path, $cookie->getPath());
  187. }
  188. /**
  189. * Test we get the correct expiry time
  190. *
  191. * @dataProvider validCookieWithInfoProvider
  192. */
  193. public function testGetExpiryTime($cStr, $cInfo)
  194. {
  195. $cookie = Zend_Http_Cookie::fromString($cStr);
  196. if (! $cookie instanceof Zend_Http_Cookie) {
  197. $this->fail("Failed creating a cookie object from '$cStr'");
  198. }
  199. if (isset($cInfo['expires'])) {
  200. $this->assertEquals($cInfo['expires'], $cookie->getExpiryTime());
  201. }
  202. }
  203. /**
  204. * Make sure the "is secure" flag is correctly set
  205. *
  206. * @dataProvider validCookieWithInfoProvider
  207. */
  208. public function testIsSecure($cStr, $cInfo)
  209. {
  210. $cookie = Zend_Http_Cookie::fromString($cStr);
  211. if (! $cookie instanceof Zend_Http_Cookie) {
  212. $this->fail("Failed creating a cookie object from '$cStr'");
  213. }
  214. if (isset($cInfo['secure'])) {
  215. $this->assertEquals($cInfo['secure'], $cookie->isSecure());
  216. }
  217. }
  218. /**
  219. * Cookie expiry time tests
  220. */
  221. /**
  222. * Make sure we get the correct value for 'isExpired'
  223. *
  224. * @dataProvider cookieWithExpiredFlagProvider
  225. */
  226. public function testIsExpired($cStr, $expired)
  227. {
  228. $cookie = Zend_Http_Cookie::fromString($cStr);
  229. if (! $cookie) {
  230. $this->fail("Failed creating a cookie object from '$cStr'");
  231. }
  232. $this->assertEquals($expired, $cookie->isExpired());
  233. }
  234. /**
  235. * Make sure we get the correct value for 'isExpired', when time is manually set
  236. */
  237. public function testIsExpiredDifferentTime()
  238. {
  239. $notexpired = time() + 3600;
  240. $expired = time() - 3600;
  241. $now = time() + 7200;
  242. $cookies = array(
  243. 'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $notexpired),
  244. 'cookie=foo; domain=example.com; expires=' . date(DATE_COOKIE, $expired)
  245. );
  246. // Make sure all cookies are expired
  247. foreach ($cookies as $cstr) {
  248. $cookie = Zend_Http_Cookie::fromString($cstr);
  249. if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
  250. $this->assertTrue($cookie->isExpired($now), 'Cookie is expected to be expired');
  251. }
  252. // Make sure all cookies are not expired
  253. $now = time() - 7200;
  254. foreach ($cookies as $cstr) {
  255. $cookie = Zend_Http_Cookie::fromString($cstr);
  256. if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
  257. $this->assertFalse($cookie->isExpired($now), 'Cookie is expected not to be expired');
  258. }
  259. }
  260. /**
  261. * Test we can properly check if a cookie is a session cookie (has no expiry time)
  262. *
  263. * @dataProvider validCookieWithInfoProvider
  264. */
  265. public function testIsSessionCookie($cStr, $cInfo)
  266. {
  267. $cookie = Zend_Http_Cookie::fromString($cStr);
  268. if (! $cookie instanceof Zend_Http_Cookie) {
  269. $this->fail("Failed creating a cookie object from '$cStr'");
  270. }
  271. if (array_key_exists('expires', $cInfo)) {
  272. $this->assertEquals(($cInfo['expires'] === null), $cookie->isSessionCookie());
  273. }
  274. }
  275. /**
  276. * Make sure cookies are properly converted back to strings
  277. *
  278. * @dataProvider validCookieWithInfoProvider
  279. */
  280. public function testToString($cStr, $cInfo)
  281. {
  282. $cookie = Zend_Http_Cookie::fromString($cStr);
  283. if (! $cookie instanceof Zend_Http_Cookie) {
  284. $this->fail("Failed creating a cookie object from '$cStr'");
  285. }
  286. $expected = substr($cStr, 0, strpos($cStr, ';') + 1);
  287. $this->assertEquals($expected, (string) $cookie);
  288. }
  289. public function testGarbageInStrIsIgnored()
  290. {
  291. $cookies = array(
  292. 'name=value; domain=foo.com; silly=place; secure',
  293. 'foo=value; someCrap; secure; domain=foo.com; ',
  294. 'anothercookie=value; secure; has some crap; ignore=me; domain=foo.com; '
  295. );
  296. foreach ($cookies as $cstr) {
  297. $cookie = Zend_Http_Cookie::fromString($cstr);
  298. if (! $cookie) $this->fail('Got no cookie object from a valid cookie string');
  299. $this->assertEquals('value', $cookie->getValue(), 'Value is not as expected');
  300. $this->assertEquals('foo.com', $cookie->getDomain(), 'Domain is not as expected');
  301. $this->assertTrue($cookie->isSecure(), 'Cookie is expected to be secure');
  302. }
  303. }
  304. /**
  305. * Test the match() method against a domain
  306. *
  307. * @dataProvider domainMatchTestProvider
  308. */
  309. public function testMatchDomain($cookieStr, $uri, $match)
  310. {
  311. $cookie = Zend_Http_Cookie::fromString($cookieStr);
  312. $this->assertEquals($match, $cookie->match($uri));
  313. }
  314. static public function domainMatchTestProvider()
  315. {
  316. $uri = Zend_Uri::factory('http://www.foo.com/some/file.txt');
  317. return array(
  318. array('foo=bar; domain=.example.com;', 'http://www.example.com/foo/bar.php', true),
  319. array('foo=bar; domain=.example.com;', 'http://example.com/foo/bar.php', true),
  320. array('foo=bar; domain=.example.com;', 'http://www.somexample.com/foo/bar.php', false),
  321. array('foo=bar; domain=example.com;', 'http://www.somexample.com/foo/bar.php', false),
  322. array('cookie=value; domain=www.foo.com', $uri, true),
  323. array('cookie=value; domain=www.foo.com', 'http://il.www.foo.com', true),
  324. array('cookie=value; domain=www.foo.com', 'http://bar.foo.com', false)
  325. );
  326. }
  327. /**
  328. * Test the match() method against a domain
  329. *
  330. */
  331. public function testMatchPath()
  332. {
  333. $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; path=/foo');
  334. $this->assertTrue($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected to match, but didn\'t');
  335. $this->assertFalse($cookie->match('http://www.example.com/bar.php'), 'Cookie expected not to match, but did');
  336. $cookie = Zend_Http_Cookie::fromString('cookie=value; domain=www.foo.com; path=/some/long/path');
  337. $this->assertTrue($cookie->match('http://www.foo.com/some/long/path/file.txt'), 'Cookie expected to match, but didn\'t');
  338. $this->assertTrue($cookie->match('http://www.foo.com/some/long/path/and/even/more'), 'Cookie expected to match, but didn\'t');
  339. $this->assertFalse($cookie->match('http://www.foo.com/some/long/file.txt'), 'Cookie expected not to match, but did');
  340. $this->assertFalse($cookie->match('http://www.foo.com/some/different/path/file.txt'), 'Cookie expected not to match, but did');
  341. }
  342. /**
  343. * Test the match() method against secure / non secure connections
  344. *
  345. */
  346. public function testMatchSecure()
  347. {
  348. // A non secure cookie, should match both
  349. $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com;');
  350. $this->assertTrue($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected to match, but didn\'t');
  351. $this->assertTrue($cookie->match('https://www.example.com/bar.php'), 'Cookie expected to match, but didn\'t');
  352. // A secure cookie, should match secure connections only
  353. $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; secure');
  354. $this->assertFalse($cookie->match('http://www.example.com/foo/bar.php'), 'Cookie expected not to match, but it did');
  355. $this->assertTrue($cookie->match('https://www.example.com/bar.php'), 'Cookie expected to match, but didn\'t');
  356. }
  357. /**
  358. * Test the match() method against different expiry times
  359. *
  360. */
  361. public function testMatchExpire()
  362. {
  363. // A session cookie - should always be valid
  364. $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com;');
  365. $this->assertTrue($cookie->match('http://www.example.com/'), 'Cookie expected to match, but didn\'t');
  366. $this->assertTrue($cookie->match('http://www.example.com/', true, time() + 3600), 'Cookie expected to match, but didn\'t');
  367. // A session cookie, should not match
  368. $this->assertFalse($cookie->match('https://www.example.com/', false), 'Cookie expected not to match, but it did');
  369. $this->assertFalse($cookie->match('https://www.example.com/', false, time() - 3600), 'Cookie expected not to match, but it did');
  370. // A cookie with expiry time in the future
  371. $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; expires=' . date(DATE_COOKIE, time() + 3600));
  372. $this->assertTrue($cookie->match('http://www.example.com/'), 'Cookie expected to match, but didn\'t');
  373. $this->assertFalse($cookie->match('https://www.example.com/', true, time() + 7200), 'Cookie expected not to match, but it did');
  374. // A cookie with expiry time in the past
  375. $cookie = Zend_Http_Cookie::fromString('foo=bar; domain=.example.com; expires=' . date(DATE_COOKIE, time() - 3600));
  376. $this->assertFalse($cookie->match('http://www.example.com/'), 'Cookie expected not to match, but it did');
  377. $this->assertTrue($cookie->match('https://www.example.com/', true, time() - 7200), 'Cookie expected to match, but didn\'t');
  378. }
  379. public function testFromStringFalse()
  380. {
  381. $cookie = Zend_Http_Cookie::fromString('foo; domain=www.exmaple.com');
  382. $this->assertEquals(false, $cookie, 'fromString was expected to fail and return false');
  383. $cookie = Zend_Http_Cookie::fromString('=bar; secure; domain=foo.nl');
  384. $this->assertEquals(false, $cookie, 'fromString was expected to fail and return false');
  385. $cookie = Zend_Http_Cookie::fromString('fo;o=bar; secure; domain=foo.nl');
  386. $this->assertEquals(false, $cookie, 'fromString was expected to fail and return false');
  387. }
  388. /**
  389. * Test that cookies with far future expiry date (beyond the 32 bit unsigned int range) are
  390. * not mistakenly marked as 'expired'
  391. *
  392. * @link http://framework.zend.com/issues/browse/ZF-5690
  393. */
  394. public function testZF5690OverflowingExpiryDate()
  395. {
  396. $expTime = "Sat, 29-Jan-2039 00:54:42 GMT";
  397. $cookie = Zend_Http_Cookie::fromString("foo=bar; domain=.example.com; expires=$expTime");
  398. $this->assertFalse($cookie->isExpired(), 'Expiry: ' . $cookie->getExpiryTime());
  399. }
  400. /**
  401. * @group ZF-10506
  402. */
  403. public function testPregMatchIsQuoted()
  404. {
  405. $this->assertFalse(Zend_Http_Cookie::matchCookieDomain('foo.bar.com', 'www.foozbar.com'));
  406. }
  407. /**
  408. * Data Providers
  409. */
  410. /**
  411. * Provide characters which are invalid in cookie names
  412. *
  413. * @return array
  414. */
  415. static public function invalidCookieNameCharProvider()
  416. {
  417. return array(
  418. array("="),
  419. array(","),
  420. array(";"),
  421. array("\t"),
  422. array("\r"),
  423. array("\n"),
  424. array("\013"),
  425. array("\014")
  426. );
  427. }
  428. /**
  429. * Provide valid cookie values
  430. *
  431. * @return array
  432. */
  433. static public function validCookieValueProvider()
  434. {
  435. return array(
  436. array('simpleCookie'),
  437. array('space cookie'),
  438. array('!@#$%^*&()* ][{}?;'),
  439. array("line\n\rbreaks"),
  440. array("0000j8CydACPu_-J9bE8uTX91YU:12a83ks4k"), // value from: Alexander Cheshchevik's comment on issue: ZF-1850
  441. // Long cookie value - 2kb
  442. array(str_repeat(md5(time()), 64))
  443. );
  444. }
  445. /**
  446. * Provider of valid reference URLs to be used for creating cookies
  447. *
  448. * @return array
  449. */
  450. static public function refUrlProvider()
  451. {
  452. return array(
  453. array(Zend_Uri::factory('http://example.com/')),
  454. array(Zend_Uri::factory('http://www.example.com/foo/bar/')),
  455. array(Zend_Uri::factory('http://some.really.deep.domain.com')),
  456. array(Zend_Uri::factory('http://localhost/path/to/very/deep/file.php')),
  457. array(Zend_Uri::factory('http://arr.gr/some%20path/text%2Ffile'))
  458. );
  459. }
  460. /**
  461. * Provide valid cookie strings with information about them
  462. *
  463. * @return array
  464. */
  465. static public function validCookieWithInfoProvider()
  466. {
  467. $now = time();
  468. $yesterday = $now - (3600 * 24);
  469. return array(
  470. array(
  471. 'justacookie=foo; domain=example.com',
  472. array(
  473. 'name' => 'justacookie',
  474. 'domain' => 'example.com',
  475. 'path' => '/',
  476. 'expires' => null,
  477. 'secure' => false
  478. )
  479. ),
  480. array(
  481. 'expires=tomorrow; secure; path=/Space Out/; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com',
  482. array(
  483. 'name' => 'expires',
  484. 'domain' => '.example.com',
  485. 'path' => '/Space Out/',
  486. 'expires' => strtotime('Tue, 21-Nov-2006 08:33:44 GMT'),
  487. 'secure' => true
  488. )
  489. ),
  490. array(
  491. 'domain=unittests; expires=' . date(DATE_COOKIE, $now) . '; domain=example.com; path=/some%20value/',
  492. array(
  493. 'name' => 'domain',
  494. 'domain' => 'example.com',
  495. 'path' => '/some%20value/',
  496. 'expires' => $now,
  497. 'secure' => false,
  498. )
  499. ),
  500. array(
  501. 'path=indexAction; path=/; domain=.foo.com; expires=' . date(DATE_COOKIE, $yesterday),
  502. array(
  503. 'name' => 'path',
  504. 'domain' => '.foo.com',
  505. 'path' => '/',
  506. 'expires' => $yesterday,
  507. 'secure' => false
  508. )
  509. ),
  510. array(
  511. 'secure=sha1; secure; SECURE; domain=some.really.deep.domain.com',
  512. array(
  513. 'name' => 'secure',
  514. 'domain' => 'some.really.deep.domain.com',
  515. 'path' => '/',
  516. 'expires' => null,
  517. 'secure' => true
  518. )
  519. ),
  520. array(
  521. 'PHPSESSID=123456789+abcd%2Cef; secure; domain=.localdomain; path=/foo/baz; expires=Tue, 21-Nov-2006 08:33:44 GMT;',
  522. array(
  523. 'name' => 'PHPSESSID',
  524. 'domain' => '.localdomain',
  525. 'path' => '/foo/baz',
  526. 'expires' => strtotime('Tue, 21-Nov-2006 08:33:44 GMT'),
  527. 'secure' => true
  528. )
  529. ),
  530. );
  531. }
  532. /**
  533. * Cookie with 'expired' flag, used to test if Cookie->isExpired()
  534. *
  535. * @return array
  536. */
  537. public static function cookieWithExpiredFlagProvider()
  538. {
  539. return array(
  540. array('cookie=foo;domain=example.com;expires=' . date(DATE_COOKIE, time() + 12 * 3600), false),
  541. array('cookie=foo;domain=example.com;expires=' . date(DATE_COOKIE, time() - 15), true),
  542. array('cookie=foo;domain=example.com;', false),
  543. array('cookie=foo;domain=example.com;expires=Fri, 01-Mar-2109 00:19:21 GMT', false),
  544. array('cookie=foo;domain=example.com;expires=Fri, 06-Jun-1966 00:19:21 GMT', true),
  545. );
  546. }
  547. }