User Management

User Session Management: A Crucial User Management Component

With online usage rising exponentially, hackers and malicious concerns are constantly trying to hijack sessions to harvest credentials or infiltrate databases. It’s no surprise that user session management is becoming a best practice in the SaaS space. Let’s take a closer look at the ins and outs of this upcoming user management methodology.

What are Session Cookies?

Cookies are basically small files of text that websites or online applications create when you access them with your browser. These cookies have sensitive private information that helps your user experience and customization requirements. 

Session cookies are cookies that stay valid only for the session you are currently in – from the time it’s launched all the way till you shut down the browser or leave the application. All relevant personal information is stored locally in a temporary location and is promptly deleted at the end of the session (ideally). Since session cookies are not stored on your device, they’re also called non-persistent cookies.

So here’s how it works:

  • The browser sends a request to website service for access permission
  • The website server generates a Session ID
  • The website server creates the session cookie with a data packet
  • The application loads in the browser
  • The session cookie is saved in the temporary memory
  • The user can start using the application/service in the browser
  • The session cookie has a record of all user inputs and activity

Please note that the session cookie is server-specific in nature and cannot be passed on to third-parties. Also, as we’ll learn in this article, while it can and should be deleted after the session is over, this does not always happen.

Related: All You Need to Know About User Authorization

What is User Session Management?

User session management involves the handling of the session cookie, authentication protocols, and also the authorization process. User sessions involve a lot of personal data and information, something that SaaS businesses need to take into consideration while planning and building their apps. There should also be a balance between security and functionality, a delicate one.

For example, ending the user session once the browser is closed is the default strategy. But many B2B use cases involve logins on a daily or even hourly basis. This is where features like “Remember Me” come into play.  That said, security should be the top priority when it comes to User Session Management. This helps reduce the attack surface and improve the compliance posture.

Mismanaged user sessions can be hacked by brute force attacks, after which the hackers can manipulate the insecure session cookies. This is known as session hijacking, commonly featured on the OWASP vulnerability lists.

User Session Management: The Best Practices   

Let’s touch on some User Session Management best practices.

  1. Revoke Session

As the name suggests, this best practice is basically gaining the ability to manually or automatically revoke user sessions that seem suspicious or that have been open for long periods of time. For example, two logins by the same authorized user, one from Bangkok and another from London, in a matter of a few minutes, represent a suspicious condition that requires immediate attention. 

Session revoking requires APIs or the sessionHandle function – which can revoke either a single session or multiple sessions. There’s also the possibility of revoking all user sessions for a specific userId, especially for the aforementioned example.

Here’s how a sessionHandle function may look in NodeJS:

2. Identify New User Sessions

With user sessions being initiated by multiple users from all kinds of locations via a wide range of devices, SaaS businesses need to be on top of things. Besides having the ability to detect unauthorized access or malicious behaviors, gaining a 360-degree view of all user sessions also helps understand customer behavior and customize the offering.

3. Limit The Number of Sessions per User

Your user management platform should be able to give you full control over user session quotas and thresholds. Use cases vary and so should your ability to define the number of user sessions per account or customers. For example, if you are looking at a banking or financial online service, it’s highly unlikely that a user will need to login more than 10 times daily. The opposite applies to productivity tools.

4. Cap the Time for User Sessions 

The same can be said about slapping time limits on user sessions. SaaS applications like Slack or Monday don’t really need this safeguard, since users are literally connected 24/7 to them. But the same cannot be said about financial, legal, banking, government, healthcare, or law enforcement verticals. Make sure your customers have the ability to implement predefined user session time limits.

5. Randomize Session IDs

First, developers love to use descriptive ID names for reference and productivity – this can be a security loophole. Secondly, hackers love to use Session ID fingerprinting. What does this mean? Popular frameworks use easily recognizable Session ID names – ASP.NET_SessionId (ASP .NET), PHPSESSID (PHP), and more. That’s why all default names should be replaced as soon as possible.

As mentioned earlier, you should also watch out for brute force or guessing attacks. Use a Cryptographically Secure Pseudorandom Number Generator (CSPRNG) to create unpredictable and random Session ID numbers for your customers/users.

Related: All You Need to Know About User Authentication

User Session Management with Frontegg   

It’s pretty clear that engineering teams now have their hands full with ongoing maintenance and security-related tasks, with user session management being one of them. But what if there was a user management platform that could shorten the time required to secure your sessions by enhancing transparency and defining various parameters with just a few clicks?

The good news is that Frontegg does just that. Besides implementing powerful authentication flows, enforcing strict authorization rules, and adding more PLG-centric features, we can get your user session management done in no time.

Self-Served User Session Management for SaaS
START FOR FREE