Skip to content

Commit

Permalink
chore: Add DeleteCookieInvoker
Browse files Browse the repository at this point in the history
  • Loading branch information
apple-x-co committed Jun 27, 2024
1 parent 4b3ff72 commit 37aadd3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/AuraSessionModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ protected function configure()
{
$this->bind(Session::class)->toConstructor(Session::class, [
'cookies' => Cookie::class,
'delete_cookie' => DeleteCookie::class
'delete_cookie' => DeleteCookie::class,
]);
$this->bind()->annotatedWith(Cookie::class)->toProvider(CookieProvider::class);
$this->bind()->annotatedWith(DeleteCookie::class)->toInstance(null);
$this->bind()->annotatedWith(DeleteCookie::class)->toInstance([new DeleteCookieInvoker(), '__invoke']);
$this->bind(SegmentFactory::class);
$this->bind(CsrfTokenFactory::class);
$this->bind(RandvalInterface::class)->to(Randval::class);
Expand Down
27 changes: 27 additions & 0 deletions src/DeleteCookieInvoker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

/**
* This file is part of the Ray.AuraSessionModule package.
*/

namespace Ray\AuraSessionModule;

use function setcookie;
use function time;

final class DeleteCookieInvoker
{
/** @param array{path: string, domain: string} $params */
public function __invoke(string $name, array $params): void
{
setcookie(
$name,
'',
time() - 42000,
$params['path'],
$params['domain']
);
}
}

0 comments on commit 37aadd3

Please sign in to comment.