Suggestion: start session safely in sessionMiddleware
terrylinooo opened this issue · 1 comments
terrylinooo commented
To prevent third-party application conflicts I suggest this.
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
So it would look like this.
class SessionMiddleware implements Middleware
{
/**
* {@inheritdoc}
*/
public function process(Request $request, RequestHandler $handler): Response
{
if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
$request = $request->withAttribute('session', $_SESSION);
}
return $handler->handle($request);
}
}
terrylinooo commented
I suggest this is because of conflicts with my work https://github.com/terrylinooo/shieldon
It is better to start safely to prevent conflicts with other libraries.