class StartSession

Properties

static protected Closure> $sessionCookieCallbacks

The callbacks used to configure the session cookie attributes.

Methods

__construct(SessionManager $manager, Factory $cache, ExceptionHandler $exceptionHandler)

Create a new session middleware.

Response
handle(Request $request, Closure $next)

Handle an incoming request.

Response
handleRequestWhileBlocking(Request $request, Session $session, Closure $next)

Handle the given request within session state.

Response
handleStatefulRequest(Request $request, Session $session, Closure $next)

Handle the given request within session state.

startSession(Request $request, Session $session)

Start the session for the given request.

getSession(Request $request)

Get the session implementation from the manager.

void
collectGarbage(Session $session)

Remove the garbage from the session if necessary.

bool
configHitsLottery(array $config)

Determine if the configuration odds hit the lottery.

void
storeCurrentUrl(Request $request, Session $session)

Store the current URL for the request if necessary.

void
addCookieToResponse(Request $request, Response $response, Session $session)

Add the session cookie to the application response.

array
resolveSessionCookieConfig(Request $request, array $config)

Get the session cookie configuration.

static void
configureSessionCookieUsing(Closure $callback)

Register a callback to configure the session cookie attributes.

void
saveSession(Request $request)

Save the session data to storage.

int
getSessionLifetimeInSeconds()

Get the session lifetime in seconds.

getCookieExpirationDate()

Get the cookie lifetime in seconds.

bool
sessionConfigured()

Determine if a session driver has been configured.

bool
sessionIsPersistent(array|null $config = null)

Determine if the configured session driver is persistent.

static void
flushState()

Flush all static state.

Details

at line 35
__construct(SessionManager $manager, Factory $cache, ExceptionHandler $exceptionHandler)

Create a new session middleware.

Parameters

SessionManager $manager
Factory $cache
ExceptionHandler $exceptionHandler

at line 45
Response handle(Request $request, Closure $next)

Handle an incoming request.

Parameters

Request $request
Closure $next

Return Value

Response

at line 64
protected Response handleRequestWhileBlocking(Request $request, Session $session, Closure $next)

Handle the given request within session state.

Parameters

Request $request
Session $session
Closure $next

Return Value

Response

at line 89
protected Response handleStatefulRequest(Request $request, Session $session, Closure $next)

Handle the given request within session state.

Parameters

Request $request
Session $session
Closure $next

Return Value

Response

at line 135
protected Session startSession(Request $request, Session $session)

Start the session for the given request.

Parameters

Request $request
Session $session

Return Value

Session

at line 147
Session getSession(Request $request)

Get the session implementation from the manager.

Parameters

Request $request

Return Value

Session

at line 157
protected void collectGarbage(Session $session)

Remove the garbage from the session if necessary.

Parameters

Session $session

Return Value

void

at line 172
protected bool configHitsLottery(array $config)

Determine if the configuration odds hit the lottery.

Parameters

array $config

Return Value

bool

at line 180
protected void storeCurrentUrl(Request $request, Session $session)

Store the current URL for the request if necessary.

Parameters

Request $request
Session $session

Return Value

void

at line 198
protected void addCookieToResponse(Request $request, Response $response, Session $session)

Add the session cookie to the application response.

Parameters

Request $request
Response $response
Session $session

Return Value

void

at line 223
protected array resolveSessionCookieConfig(Request $request, array $config)

Get the session cookie configuration.

Parameters

Request $request
array $config

Return Value

array

at line 251
static void configureSessionCookieUsing(Closure $callback)

Register a callback to configure the session cookie attributes.

Boot-only. The callback persists in a static property for the worker lifetime and runs on every session cookie write across all coroutines. Callbacks run in registration order; later callbacks receive the values returned by earlier callbacks and may overwrite them.

Parameters

Closure $callback

Return Value

void

at line 259
protected void saveSession(Request $request)

Save the session data to storage.

Parameters

Request $request

Return Value

void

at line 269
protected int getSessionLifetimeInSeconds()

Get the session lifetime in seconds.

Return Value

int

at line 277
protected DateTimeInterface|int getCookieExpirationDate()

Get the cookie lifetime in seconds.

Return Value

DateTimeInterface|int

at line 289
protected bool sessionConfigured()

Determine if a session driver has been configured.

Return Value

bool

at line 297
protected bool sessionIsPersistent(array|null $config = null)

Determine if the configured session driver is persistent.

Parameters

array|null $config

Return Value

bool

at line 307
static void flushState()

Flush all static state.

Return Value

void