Session Object
● is Java Object
● is stored on the Server (either in the Memory or in the Database)
● is used to track different Users (different Session Object is assigned to each User)
● contains User related data (like is User Authenticated, User's Role and Username)
JSESSIONID
● is Cookie
● is stored in the Browser
● is used to track different Users (different JSESSIONID is returned to each User)
● contains ID that uniquely identifies Session Object (assigned to that User)
● is received from Server after successful Authentication (after User provided valid Username and Password)
● is sent to Server with every HTTP Request
● is used by Server to identify User's Session Object
JSESSIONID and Session Object are used to track different Users between subsequent HTTP Requests (and their data).
● This way Server can for instance know if User has already Authenticated (by providing valid Username and Password)
in order to allow User access to restricted Resource in subsequent TTP Requests.
● For instance upon successful Authentication, Server can store authenticated=true and userRole=ADMIN in User's
Session Object and return JSESSIONID Cookie to uniquely identify created Session Object. Then when that User sends
next HTTP Request together with stored JSESSIONID Cookie, Server will use JSESSIONID to retrieve User's Session
Object and will allow him to access restricted Resource based on User's Role ADMIN.
● For another User Server would create different Session Object and JSESSIONID Cookie to identify it. For that User upon
successful Authentication Server can store authenticated=true and userRole=USER in User's Session Object. Then
when User sends next HTTP Request Server will allow him to access restricted Resource based on User's Role USER.
Session Object Example
id = JSESSIONID
userID = 5248
userName = John
userRole = USER
authenticated = true
Initial HTTP Request
Subsequent HTTP Requests