This is a single worked example, start to finish. The system is an imaginary bus-booking site, “Sahyadri Tickets”, with a login, a seat-selection page, a payment page and a profile page. The goal is to test how the site handles a session: the period during which the server recognises you as the same logged-in person without asking for the password again. We will go step by step and note what each step teaches.

Step 0: what a session is, mechanically

HTTP has no memory. Each request arrives alone. To remember you, the server, after you log in, creates a session and hands your browser an identifier, usually in a cookie. The browser sends that cookie back with every later request, and the server looks it up. Some systems use a signed token (for example a JWT) instead, but the testing questions are close to identical: what does the identifier let me do, how long does it live, and what ends it?

Step 1: log in and inspect the cookie

Log in with a valid account. Open developer tools and find the cookies (the Application tab in Chrome, Storage in Firefox). You will see a session cookie with attributes next to it. Three are worth checking:

  • HttpOnly means page scripts cannot read the cookie, which limits what an injected script can steal.
  • Secure means it is sent only over HTTPS.
  • SameSite controls whether the cookie accompanies requests triggered from other sites, which relates to cross-site request forgery.

On our site, say the session cookie has none of the three. That is a finding already, before any clicking. Note the value of the identifier too, because we will compare it shortly.

Step 2: log out, and log in again

Log out, then log in again and look at the identifier. It should be different from before. If a fresh login reuses a pre-login identifier, the site is open to session fixation, where an attacker plants a known identifier and waits for the victim to log in with it. The rule you are verifying: the identifier must change at the moment of authentication. Our site passes; the value changed.

Step 3: the back button after logout

Open the profile page, which shows the user’s name and phone number. Click Logout. Now press the browser’s Back button. On a shared computer, say a cyber café, this matters a great deal. Three outcomes are possible. The page may redirect to login (good). It may show the cached profile page from memory (a defect for sensitive data, usually fixed with proper no-store caching instructions from the server). Or it may show the page, and clicking anything then fails (half-good: the server is safe but the screen leaked data).

On Sahyadri, Back shows the profile page with the phone number. The server was right to end the session, but the browser was allowed to keep a copy. Logged as a defect against the cache headers on authenticated pages.

Step 4: does logout really end the session?

This one tests the server, not the screen. Log in, copy the session cookie value (or capture a request in an API client), log out in the browser, then replay a request with the old cookie. A correct system rejects it, typically with a 401, because the session was invalidated on the server. A weak system merely deletes the cookie from the browser, and the old identifier keeps working until it expires. Token-based setups have a related trade-off: a stateless token cannot be recalled unless the server keeps a deny-list or the token lives only briefly, so “logout” may mean something weaker there. Whether that is acceptable is a risk decision, but you should know which behaviour you have.

Step 5: idle timeout and absolute timeout

There are two different clocks. The idle timeout ends a session after a period of inactivity. The absolute timeout ends it after a fixed lifetime however busy the user is. Ask the product owner what the values should be. Suppose the answer is 15 minutes idle and 8 hours absolute. Testing 15 minutes means waiting 15 minutes, or asking for a short test-environment configuration, which is usually better. Then check four things:

First, does any activity (a real request, not just mouse movement on a static page) reset the idle timer? Second, what does the user see when it expires: a redirect to login, with the intended page remembered, or a blank error? Third, if the expiry hits during seat selection, is the half-finished booking lost silently? Fourth, what if it expires between clicking Pay and the response? That last one is the nasty one, because a payment might succeed while the user sees a login page. It deserves a conversation with the developers about how the order is reconciled.

Step 6: two tabs, two devices

Open the site in two tabs of the same browser. Log out in tab A. In tab B, click something that needs a session. It should fail gracefully, not show a confusing half-page. Next, log in on a laptop and on a phone with the same account. Does the business allow concurrent logins? Some products permit them; some cap the number of devices; some log the older one out. Whichever the rule is, test that it is enforced, and test that changing the password ends the other sessions, a behaviour users commonly expect.

What the walkthrough shows

Six steps, about two hours with the timeout waits, and four findings on an imaginary site: missing cookie attributes, cached sensitive page, possibly a weak logout depending on step 4, and an unclear expiry during payment. None of them would show up if you only tested that login works with a valid password. Session behaviour is invisible when everything goes right, which is why it hides so well.

The limits: this covers functional behaviour. Deep session security (token entropy, brute-forcing identifiers) belongs to a security specialist with proper authorisation. And the exact defaults differ by framework, so check what your stack does before assuming a finding is a bug in your own code.

Figures and names in the examples are illustrative.

Leave a Reply

Trending