The Session Layer is the fifth layer of the OSI model. It establishes, manages, and terminates the sessions between applications running on different devices.
- It sits between the Presentation Layer above and the Transport Layer below, and it controls the dialogue between the two communicating applications.
- In modern TCP/IP networks, many of its functions, such as session release and dialogue control, are handled by the Transport and Application layers, so it has little independent role there.

Need for the Session Layer
Without a session layer, applications would face these problems during long or complex exchanges:
- If the connection fails midway through a large transfer, the whole transfer has to start again.
- Both devices may send data at the same time, which causes collisions.
- A session may be closed before all the data has been delivered.
Working
The Session Layer manages a session in five stages, from setting up the connection to closing it. The figure below shows these stages between two applications.

- Connection establishment: The two applications agree on the session parameters, such as authentication and the duplex mode, before any data is sent.
- Data exchange: Tokens are used to manage the dialogue, so only the device holding the token sends data at a time and collisions are avoided.
- Synchronization: Checkpoints are inserted into the data stream, so that after a failure the transfer resumes from the last checkpoint.
- Orderly communication: The layer keeps the exchange in proper order and reduces message loss, duplication, and errors.
- Connection termination: Once all the data is exchanged and confirmed, the session is closed gracefully.
Session Layer Protocols
- AppleTalk Data Stream Protocol (ADSP): Developed by Apple for communication between nodes on a LAN, with support for self-configuration.
- Real-time Transport Control Protocol (RTCP): Provides quality of service feedback for multimedia sessions that use RTP.
- Point-to-Point Tunneling Protocol (PPTP): Enables Virtual Private Networks (VPNs) over TCP/IP.
- Password Authentication Protocol (PAP): Provides password-based user authentication in PPP connections.
- Remote Procedure Call (RPC): Allows a program to execute procedures in another address space, as in client-server interaction.
- Sockets Direct Protocol (SDP): Supports socket communication over RDMA-enabled networks.

