session property

Session? get session

Gets the session.

The session may be set explicitly with the session setter or from the session in the request (if there was one).

Returns null if there was no session in the request and session was not used to set it to a non-null value.

Implementation

Session? get session => _sessionInResponse;
set session (Session? s)

Convenience method for setting the session.

Originally, to change the session, it needs to be changed o the request object. But often for convenience, it is easier to set it on the response object.

Note: this only works when cookies are used to manage state.

Implementation

set session(Session? s) {
  _sessionSetInResponse = true;
  _sessionInResponse = s;
}