This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Boot 3.3.4!spring-doc.cn

This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Boot 3.3.4!spring-doc.cn

The sessions endpoint provides information about the application’s HTTP sessions that are managed by Spring Session.spring-doc.cn

Retrieving Sessions

To retrieve the sessions, make a GET request to /actuator/sessions, as shown in the following curl-based example:spring-doc.cn

$ curl 'http://localhost:8080/actuator/sessions?username=alice' -i -X GET

The preceding examples retrieves all of the sessions for the user whose username is alice. The resulting response is similar to the following:spring-doc.cn

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 789

{
  "sessions" : [ {
    "id" : "8b20b7be-b5fb-4c74-b974-e3e7fe1e74ce",
    "attributeNames" : [ ],
    "creationTime" : "2024-10-03T17:30:37.821596545Z",
    "lastAccessedTime" : "2024-10-03T19:30:25.821599250Z",
    "maxInactiveInterval" : 1800,
    "expired" : false
  }, {
    "id" : "305705a9-a5ae-4358-b860-8bf39e0b394c",
    "attributeNames" : [ ],
    "creationTime" : "2024-10-03T07:30:37.820752435Z",
    "lastAccessedTime" : "2024-10-03T19:29:52.820757855Z",
    "maxInactiveInterval" : 1800,
    "expired" : false
  }, {
    "id" : "4db5efcc-99cb-4d05-a52c-b49acfbb7ea9",
    "attributeNames" : [ ],
    "creationTime" : "2024-10-03T14:30:37.821591435Z",
    "lastAccessedTime" : "2024-10-03T19:30:00.821593940Z",
    "maxInactiveInterval" : 1800,
    "expired" : false
  } ]
}

Query Parameters

The endpoint uses query parameters to limit the sessions that it returns. The following table shows the single required query parameter:spring-doc.cn

Parameter Description

usernamespring-doc.cn

Name of the user.spring-doc.cn

Response Structure

The response contains details of the matching sessions. The following table describes the structure of the response:spring-doc.cn

Path Type Description

sessionsspring-doc.cn

Arrayspring-doc.cn

Sessions for the given username.spring-doc.cn

sessions.[].idspring-doc.cn

Stringspring-doc.cn

ID of the session.spring-doc.cn

sessions.[].attributeNamesspring-doc.cn

Arrayspring-doc.cn

Names of the attributes stored in the session.spring-doc.cn

sessions.[].creationTimespring-doc.cn

Stringspring-doc.cn

Timestamp of when the session was created.spring-doc.cn

sessions.[].lastAccessedTimespring-doc.cn

Stringspring-doc.cn

Timestamp of when the session was last accessed.spring-doc.cn

sessions.[].maxInactiveIntervalspring-doc.cn

Numberspring-doc.cn

Maximum permitted period of inactivity, in seconds, before the session will expire.spring-doc.cn

sessions.[].expiredspring-doc.cn

Booleanspring-doc.cn

Whether the session has expired.spring-doc.cn

Parameter Description

usernamespring-doc.cn

Name of the user.spring-doc.cn

Path Type Description

sessionsspring-doc.cn

Arrayspring-doc.cn

Sessions for the given username.spring-doc.cn

sessions.[].idspring-doc.cn

Stringspring-doc.cn

ID of the session.spring-doc.cn

sessions.[].attributeNamesspring-doc.cn

Arrayspring-doc.cn

Names of the attributes stored in the session.spring-doc.cn

sessions.[].creationTimespring-doc.cn

Stringspring-doc.cn

Timestamp of when the session was created.spring-doc.cn

sessions.[].lastAccessedTimespring-doc.cn

Stringspring-doc.cn

Timestamp of when the session was last accessed.spring-doc.cn

sessions.[].maxInactiveIntervalspring-doc.cn

Numberspring-doc.cn

Maximum permitted period of inactivity, in seconds, before the session will expire.spring-doc.cn

sessions.[].expiredspring-doc.cn

Booleanspring-doc.cn

Whether the session has expired.spring-doc.cn

Retrieving a Single Session

To retrieve a single session, make a GET request to /actuator/sessions/{id}, as shown in the following curl-based example:spring-doc.cn

$ curl 'http://localhost:8080/actuator/sessions/4db5efcc-99cb-4d05-a52c-b49acfbb7ea9' -i -X GET

The preceding example retrieves the session with the id of 4db5efcc-99cb-4d05-a52c-b49acfbb7ea9. The resulting response is similar to the following:spring-doc.cn

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 208

{"id":"4db5efcc-99cb-4d05-a52c-b49acfbb7ea9","attributeNames":[],"creationTime":"2024-10-03T14:30:37.821591435Z","lastAccessedTime":"2024-10-03T19:30:00.821593940Z","maxInactiveInterval":1800,"expired":false}

Response Structure

The response contains details of the requested session. The following table describes the structure of the response:spring-doc.cn

Path Type Description

idspring-doc.cn

Stringspring-doc.cn

ID of the session.spring-doc.cn

attributeNamesspring-doc.cn

Arrayspring-doc.cn

Names of the attributes stored in the session.spring-doc.cn

creationTimespring-doc.cn

Stringspring-doc.cn

Timestamp of when the session was created.spring-doc.cn

lastAccessedTimespring-doc.cn

Stringspring-doc.cn

Timestamp of when the session was last accessed.spring-doc.cn

maxInactiveIntervalspring-doc.cn

Numberspring-doc.cn

Maximum permitted period of inactivity, in seconds, before the session will expire.spring-doc.cn

expiredspring-doc.cn

Booleanspring-doc.cn

Whether the session has expired.spring-doc.cn

Path Type Description

idspring-doc.cn

Stringspring-doc.cn

ID of the session.spring-doc.cn

attributeNamesspring-doc.cn

Arrayspring-doc.cn

Names of the attributes stored in the session.spring-doc.cn

creationTimespring-doc.cn

Stringspring-doc.cn

Timestamp of when the session was created.spring-doc.cn

lastAccessedTimespring-doc.cn

Stringspring-doc.cn

Timestamp of when the session was last accessed.spring-doc.cn

maxInactiveIntervalspring-doc.cn

Numberspring-doc.cn

Maximum permitted period of inactivity, in seconds, before the session will expire.spring-doc.cn

expiredspring-doc.cn

Booleanspring-doc.cn

Whether the session has expired.spring-doc.cn

Deleting a Session

To delete a session, make a DELETE request to /actuator/sessions/{id}, as shown in the following curl-based example:spring-doc.cn

$ curl 'http://localhost:8080/actuator/sessions/4db5efcc-99cb-4d05-a52c-b49acfbb7ea9' -i -X DELETE

The preceding example deletes the session with the id of 4db5efcc-99cb-4d05-a52c-b49acfbb7ea9.spring-doc.cn