-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
131 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Selective\SameSiteCookie; | ||
|
||
/** | ||
* SameSite Cookie Configuration. | ||
*/ | ||
final class PhpSessionHandler implements SessionHandlerInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getId(): string | ||
{ | ||
return (string)session_id(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function start(): void | ||
{ | ||
session_start(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getName(): ?string | ||
{ | ||
return (string)session_name(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getCookieParams(): array | ||
{ | ||
return (array)session_get_cookie_params(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function isStarted(): bool | ||
{ | ||
return session_status() !== PHP_SESSION_ACTIVE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Selective\SameSiteCookie; | ||
|
||
/** | ||
* The SessionHandlerInterface. | ||
*/ | ||
interface SessionHandlerInterface | ||
{ | ||
/** | ||
* Get session id. | ||
* | ||
* @return string The id | ||
*/ | ||
public function getId(): string; | ||
|
||
/** | ||
* Start session. | ||
* | ||
* @retrun void | ||
*/ | ||
public function start(): void; | ||
|
||
/** | ||
* Get session name. | ||
* | ||
* @return string|null The name | ||
*/ | ||
public function getName(): ?string; | ||
|
||
/** | ||
* Get cookie params. | ||
* | ||
* @return array<mixed> The params | ||
*/ | ||
public function getCookieParams(): array; | ||
|
||
/** | ||
* Is session started. | ||
* | ||
* @return bool The session status | ||
*/ | ||
public function isStarted(): bool; | ||
} |