/** * Close previous session and create a new empty one. */ protected function recreateSession() { $_SESSION = []; session_unset(); session_destroy(); session_id(SessionWare::generateSessionId()); session_start(); }
/** * @runInSeparateProcess * @preserveGlobalState disabled */ public function testSessionIdFromRequest() { $sessionId = SessionWare::generateSessionId(); $request = ServerRequestFactory::fromGlobals(null, null, null, ['SessionWareSession' => $sessionId]); $middleware = new SessionWare(['name' => 'SessionWareSession']); /** @var Response $response */ $response = $middleware($request, $this->response, $this->callback); self::assertEquals(PHP_SESSION_ACTIVE, session_status()); self::assertNotSame(strpos($response->getHeaderLine('Set-Cookie'), $sessionId), false); }