Back to Editorial
Engineering8 min read

USSD Session Management Explained: Handling Statelessness

Avatar of Asterisks Engineering
Asterisks Engineering
Core Team ·
Diagram illustrating USSD session state being persisted in a distributed cache.

The Challenge of Statelessness

USSD is a session-oriented protocol built on a stateless HTTP foundation. Every time a user types a number, your server receives a brand new request. Without proper session management, your app has no "memory."

Using Session IDs

Telco gateways provide a SessionId. This is your primary key. You must use this ID to look up the user's current state (e.g., "they are on page 3 of the registration flow").

Persistence Strategies

  1. In-Memory (Redis): Fastest, but sessions are lost if the cache clears.
  2. Database (PostgreSQL/MongoDB): Reliable, but adds latency.
  3. Asterisks Managed State: Our engine handles this automatically, using a tiered caching strategy to ensure sub-100ms response times.

Handling Timeouts

USSD sessions typically timeout after 20-30 seconds of inactivity. Your session management system must:

  • Detect expired sessions.
  • Clean up resources.
  • Decide whether to let the user "resume" or start over.

Understanding session state is what separates a basic menu from a serious USSD application.

Topics

  • USSD
  • Session Management
  • State Management
  • Engineering
  • Redis
Avatar of Asterisks Engineering

About the author

Asterisks Engineering is the Core Team and a veteran in the African telecommunications space, focusing on building accessible technology for the next billion users.

View all posts