getSession abstract method

HttpSession? getSession([
  1. bool create = true
])

Returns the current HttpSession associated with this request, or optionally creates one.

If create is true (the default), a new session will be created if none exists. If create is false, and there is no current session, null will be returned.

Example

final session = request.getSession(false);
if (session != null) {
  print('User: ${session.getAttribute('user')}');
}

Parameters

  • create: whether to create a new session if none exists.

Returns

The current HttpSession, or null if none exists and create is false.

Implementation

HttpSession? getSession([bool create = true]);