The Session Layer, Explained

UPI Study › Courses › Introduction to Operating Systems › Free lessons › Lesson 8.1 Free with a free account

The Session Layer

Introduction to Operating Systems · Chapter 8: The Internet, Connectivity, and Network OperationsSection 8.1 · lesson 62 of 838 min · free with a free account

← The Transport LayerNext lesson: The History of the Internet →

A free account plays all of Chapter 1 and 3 more lessons of Introduction to Operating Systems. Create a free account →

Earn 3 college credits for Introduction to Operating SystemsRecommended for credit by NCCRS · Computer Science 354 · self-paced · one payment, lifetime access

In this lesson

How sessions open, stay alive, close and resume across connections.

  • Define a session and place the session layer in the OSI model
  • Trace how a web login token opens, carries and closes a session
  • Explain keep-alives, timeouts and simplex, half-duplex and full-duplex dialog
  • Calculate how many chunks a checkpointed transfer sends after a break

Free study notes

Get this lesson's notes by email

The key points and 4 practice questions with answers, in your inbox. One email, free.

One email. Unsubscribe in one click.

Transcript

Everything said in the video, section by section (1,095 words). Read along, or search it.

Opening Analogy

A Phone Call in Three Parts

A phone call has three parts that you never think about. Someone dials, and the other person answers. That opens the call. You talk, and now and then you ask: are you still there? That keeps it going. At the end, you say goodbye and hang up. That closes it. Computers hold conversations in the same shape. The layer in charge of them is called the session layer. It's the reason a shop site still knows you're logged in, when you click through to the next page.

Definition

A Conversation With Memory

A session is an ongoing conversation between two programs, with a start and an end. During it, they remember things about each other: who you are, what you've already done, and what comes next. In the OSI model from lesson 7.2, the session layer is layer five. It sits just above the transport layer, from lesson 7.6, and just below the presentation layer, from lesson 7.5. Why a separate idea? Because most network protocols forget everything between requests. A web server answers one request, and the next one arrives as if from a stranger. A session adds memory on top, so a conversation can outlast any single message.

Three Phases

Open, Maintain and Close

One honest note. The TCP/IP model has no separate session layer. There, programs at the application layer do this job themselves, with tokens, timers, and library calls. OSI keeps it as a layer, so that the job has a name. Whoever does it, every session goes through the same three phases. Here are three sessions, phase by phase. A web login: a password is checked, and a token is issued. The token rides along with each page. Logout or a timeout deletes it. A video call: ring, answer, and agree on formats. Keep-alive signals flow while it's quiet. Then hang up, and free the line. A large file transfer: agree on the file's name and size. Save checkpoints as data arrives. Then confirm the end, and release the file.

Worked Example

A Login Token Step by Step

Now a web login, step by step. Sam, who runs a small online bakery, logs in to the shop's admin page. The browser sends the user name and the password. A wrong password gets nothing back. A right one makes the server open a session. It makes up a long random token, and remembers that this token belongs to Sam. The token goes back to the browser, which keeps it, usually in a cookie. From then on, the browser attaches the token to every request. Show me the orders, and here's my token. The server looks the token up, and answers: hello Sam, here are your orders. The memory lives in that lookup table.

Closing a Session

Logout and Timeouts Delete the Token

Closing matters as much as opening. When Sam logs out, the server deletes that token from its table. The browser may still hold the old token. But now it means nothing. The same request gets: please log in. Real sites also close a session by timeout, after a quiet spell. Lesson 9.8 covers this and other protections. Banks use short timeouts on purpose. A forgotten open session, on a shared computer, is a risk.

Staying Healthy

Keep-Alives, Timeouts and Dialog Control

Between opening and closing, a session has to stay healthy. The session layer has three jobs here. Keep-alive messages: tiny still-here signals, so that an idle link isn't mistaken for a dead one. Timeouts: a session that's been quiet for too long is closed, to free its resources. And dialog control: deciding who may talk, and when. Talk can go one way only, called simplex, like a TV broadcast. One way at a time, called half-duplex, like a walkie-talkie. Or both ways at once, called full-duplex, like a phone call. A video call uses all of this. Hello signals flow even when nobody speaks, and the call adjusts when the link slows down.

Quick Check

A Ten-Second Wi-Fi Drop

Quick check. Sam is on the orders page, when the Wi-Fi drops for ten seconds. When it comes back, the browser has to open a brand-new TCP connection to the shop server. Then Sam clicks through to the next page. What does the server do? Pause, and decide. It greets Sam by name. The browser sends the same token over the new connection, and that token is still in the server's table. Log in again is the tempting pick. But a session isn't a connection. The session lives in the server's memory and in the token, not in the wire. A new token comes only with a new login. That's why a short Wi-Fi drop doesn't log you out, unless a timeout has already ended the session.

Checkpoints

Resuming From the Last Safe Point

One more session tool: checkpoints. Sam was uploading a four-gigabyte video for a shop ad, when the Wi-Fi dropped near the end. Starting over would waste a long time. A checkpoint is a saved marker: everything up to here arrived safely. The OSI model calls these synchronization points. After a break, both sides resume from the last one. Picture a transfer of ten chunks, with a checkpoint saved after every third chunk. The link dies after chunk seven. The last checkpoint was at chunk six, so only chunks seven to ten are sent again. That's seven chunks before the break, plus four after: eleven in all. Starting from zero would have sent seventeen. More frequent checkpoints waste less on a break, but each one costs a little work to save. Sam's upload tool kept markers like these. After reconnecting, it picked up from the last one, and finished in a minute.

Quick Check

Counting Chunks After a Break

Quick check. Ivy, who looks after the computers at a school, copies a twelve-chunk backup to a server. A checkpoint is saved after every fourth chunk. The link breaks right after chunk ten. Counting both tries, how many chunks are sent in all? Pause, and predict. Fourteen. The checkpoints fall after chunks four and eight, so the last safe point before the break is eight. Chunks nine to twelve go again. That's four more, on top of the ten already sent. Twelve is tempting, but it resumes right after chunk ten, and nothing marked ten as safe. Twenty-two would mean starting from zero.

Key Takeaways

Sessions Outlive Connections

To recap. A session is a conversation with memory: opened, maintained, and closed. On the web, a token carries the session. Logout or a timeout deletes it on the server. Keep-alives, timeouts, and dialog control keep a session healthy, and it outlives a dropped connection. Checkpoints let a broken transfer resume from the last safe point.

Think About It

Short Timeouts Versus Long Ones

Something to think about. Your bank logs you out after a few quiet minutes, but a video site keeps you logged in for weeks. Why might each one choose its timeout that way?

About Introduction to Operating Systems at UPI Study

Introduction to Operating Systems (Computer Science 354) is a self-paced online course of 83 video lessons in 10 chapters, from what an operating system does and process scheduling to concurrency, memory, devices, file systems, networks, the internet, security and virtual machines. It carries a NCCRS credit recommendation for 3 semester credits.

Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Compare: Linux vs Operating Systems

Why take it here

Why students take Introduction to Operating Systems with UPI Study

What happens under every app you runIntroduction to Operating Systems explains the software that runs a computer: processes and scheduling, threads and synchronization, deadlock, memory and paging, devices and storage, file systems, networking, security and virtualization. It suits computer science and information technology degrees.
Credit at a fraction of the priceThe same 3 credits can cost $750 or more at a US college. Here it is one payment, self-paced, with lifetime access.
Finish your degree soonerTransfer credits reduce the courses you still owe, so you can graduate earlier or lighten a heavy semester.
Strengthen an applicationA completed college-level course on an official transcript shows admissions and scholarship committees you can do the work.
Study on your own scheduleNo start dates, no deadlines. Watch the lessons, practice, and take the final when you are ready.
130,000+students helped with college creditsACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Where the credit goes

Universities that work with NCCRS

Introduction to Operating Systems carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.

FAQ

Questions students ask us

About The Session Layer

What is the difference between a session and a connection?
A session is an ongoing conversation that remembers who you are, while a connection is a single link that carries messages. On the web, the server keeps a session token in a table and the browser sends it with each request. If the connection drops and a new one opens, the same token still works, so the session survives unless a timeout or logout has ended it.
How does a session token keep a user logged in?
A session token keeps a user logged in by standing in for the password on each later request. After a correct login, the server makes a long random token, records whose it is, and sends it to the browser, usually in a cookie. The browser attaches it to every request, and the server looks it up. Logging out or a timeout deletes the token on the server.
What is the difference between simplex, half-duplex and full-duplex?
Simplex lets data flow one way only, half-duplex allows both directions but one at a time, and full-duplex allows both directions at once. A TV broadcast is simplex, a walkie-talkie is half-duplex, and a phone call is full-duplex. Deciding who may talk and when is called dialog control, one of the jobs the OSI model gives the session layer.
How do checkpoints help resume a file transfer?
Checkpoints mark points where everything sent so far arrived safely, so after a break the transfer resumes from the last one instead of from zero. With ten chunks and a checkpoint after every third, a break after chunk seven resends chunks seven to ten, for eleven sends in all rather than seventeen. More frequent checkpoints waste less after a break but cost a little work to save.

About the Introduction to Operating Systems course

How many college credits is Introduction to Operating Systems?
Introduction to Operating Systems (Computer Science 354) carries a NCCRS credit recommendation for 3 semester credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
How much does Introduction to Operating Systems cost and what is included?
$250, paid once, with lifetime access: all 83 video lessons, a practice quiz after each, the graded work and final exam, and an official transcript when you finish. Students who want several courses choose UPI Study PRO instead.
Which universities accept UPI Study credits?
UPI Study has signed partner agreements with universities such as Thomas Edison State University, University of the People and Charter Oak State College, and works with universities such as Penn State, SNHU and SUNY. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities. Use "Find my college" on this page to check yours.
How long does Introduction to Operating Systems take?
It is self-paced with no deadlines. The 83 lessons total about 10 hours of video; most students add reading and practice time and finish in a few weeks to a few months, on their own schedule.
How are the exams done?
Quizzes and assignments are online in the course. The final exam is taken online with proctoring; a person on the UPI Study team checks assignments, usually within two days.
How do my credits reach my college?
When the course shows 100% complete, request the official transcript from your dashboard. It is sent to the college you name, and you can send it to more than one. Check your college first with "Find my college" on this page, or ask Athena.

Ready for the full course? Earn 3 credits in Introduction to Operating Systems.

83 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.

Updated

Introduction to Operating Systems
3 credits · NCCRS
Enroll →