delight-im / PHP-Cookie

Modern cookie management for PHP
MIT License
165 stars 48 forks source link

Cookie Parse Error #20

Closed Lednerb closed 6 years ago

Lednerb commented 6 years ago

Hello,

I'm using this library to simplify my tests for cookies that have set the secure and httpOnly flags.

However, regarding this specification, only the cookiename=value is required, all other directives are optional: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#Directives

When I'm using:

$cookie = Cookie::parse("Set-Cookie: session=myCookie");
$cookie->isSecureOnly();

I get the following error:

Error: Call to a member function isSecureOnly() on null

Same with $cookie->isHttpOnly().


There is an error in this regex, I think: https://github.com/delight-im/PHP-Cookie/blob/master/src/Cookie.php#L380

ocram commented 6 years ago

Thank you very much!

Fixed in https://github.com/delight-im/PHP-Cookie/commit/deecb7d2f5a27a17ad2f89b58d3130ee72272ef4.

Lednerb commented 6 years ago

Thank you for your fast support.