diff --git a/README.md b/README.md index ef43829..570cee7 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,13 @@ composer require innmind/http-session ```php use Innmind\HttpSession\Manager\Native; use Innmind\Http\{ - Message\Response\Response, - Message\ServerRequest, - Message\StatusCode, + Response, + Response\StatusCode, + ServerRequest, Headers, Header\SetCookie, - Header\CookieParameter\HttpOnly, - Header\CookieParameter\Domain, - Header\Parameter\Parameter, + Header\SetCookie\Directive, + Header\SetCookie\Domain, }; $manager = Native::of(); @@ -39,18 +38,20 @@ $session = $manager->start($request)->match( // inject some data in the session $manager->save($session); -$response = new Response( - $code = StatusCode::ok, +$response = Response::of( + StatusCode::ok, $request->protocolVersion(), Headers::of( SetCookie::of( - new Parameter($session->name()->toString(), $session->id()->toString()), - new HttpOnly, - new Domain($request->url()->authority()->host()), + $session->name()->toString(), + $session->id()->toString(), + Directive::httpOnly, + Domain::of($request->url()->authority()->host()), ), ), ); // send the response ``` -**Note**: you should take a look at [`innmint/http-server`](https://github.com/Innmind/HttpServer) in order to know how to have access to an instance of `ServerRequest` and send the `Response`. +> [!NOTE] +> You should take a look at [`innmind/http-server`](https://github.com/Innmind/HttpServer) in order to know how to have access to an instance of `ServerRequest` and send the `Response`. diff --git a/composer.json b/composer.json index 2df0bfb..20471d5 100644 --- a/composer.json +++ b/composer.json @@ -16,9 +16,7 @@ }, "require": { "php": "~8.2", - "innmind/immutable": "~4.9|~5.0", - "innmind/http": "~7.0", - "innmind/validation": "~1.0" + "innmind/foundation": "~1.3" }, "autoload": { "psr-4": { diff --git a/src/Manager/Native.php b/src/Manager/Native.php index cec1dfe..d063ea4 100644 --- a/src/Manager/Native.php +++ b/src/Manager/Native.php @@ -12,13 +12,11 @@ use Innmind\Http\{ ServerRequest, Header\Cookie, - Header\CookieValue, }; use Innmind\Validation\Is; use Innmind\Url\Path; use Innmind\Immutable\{ Map, - Sequence, Maybe, SideEffect, }; @@ -137,10 +135,9 @@ private function configureSessionId(ServerRequest $request): void } $sessionName = \session_name(); - /** @var Sequence */ - $values = Sequence::of(...$cookie->values()->toList()); - $_ = $values - ->flatMap(static fn($value) => $value->parameters()->values()) + $_ = $cookie + ->parameters() + ->values() ->find(static fn($parameter) => $parameter->name() === $sessionName) ->match( static fn($parameter) => \session_id($parameter->value()),