Skip to main content

Session Authentication

Session authentication is designed for browser-based applications where users log in through the FLTR web interface. It uses HTTP-only cookies for secure, stateless authentication.

Overview

Session authentication provides:
  • 15,000 requests/hour rate limit
  • HTTP-only cookies to prevent XSS attacks
  • CSRF protection built-in
  • Automatic session management by the browser
  • Same security as OAuth without the complexity

When to Use Sessions

Best for:
  • Single-page applications (SPAs)
  • Server-rendered web apps
  • Admin dashboards
  • Internal tools
Not recommended for:
  • Mobile apps (use OAuth)
  • Server-to-server integrations (use API keys)
  • Third-party integrations (use OAuth)

Quick Start

1

Enable Session Auth

Configure your application to use credentials:
2

Redirect to Login

Send users to the FLTR login page:
3

Make API Calls

After login, session cookies are automatically included:

Implementation

Frontend (React Example)

Backend (Express.js Example)

If you need server-side session management:

CORS Configuration

For browser-based requests, configure CORS properly:

Development

Production

Add your domain to FLTR’s allowed origins:
  1. Go to SettingsCORS
  2. Add your production domain: https://yourdomain.com
  3. Save changes
FLTR will send these CORS headers:

CSRF Protection

Session authentication includes built-in CSRF protection using the double-submit cookie pattern.

How It Works

  1. FLTR sets a CSRF token in a cookie
  2. Your app reads the cookie and sends it in a header
  3. FLTR validates the header matches the cookie

Implementation

Axios Configuration

Axios automatically handles CSRF tokens:

Session Management

Check Session Status

Extend Session

Sessions automatically extend on each request. To manually extend:

Logout

Security Best Practices

FLTR sets secure cookie attributes:

Frontend Security

Do:
  • ✅ Use credentials: 'include' for all API requests
  • ✅ Implement CSRF protection
  • ✅ Use HTTPS in production
  • ✅ Validate session before sensitive operations
  • ✅ Implement logout on idle timeout
Don’t:
  • ❌ Store session data in localStorage
  • ❌ Access cookies from JavaScript
  • ❌ Make API calls without CSRF tokens
  • ❌ Trust client-side session checks alone

Backend Security

Do:
  • ✅ Use httpOnly cookies
  • ✅ Set SameSite=Lax or Strict
  • ✅ Implement session expiry
  • ✅ Validate CSRF tokens
  • ✅ Use secure session stores (Redis)
Don’t:
  • ❌ Store sessions in memory (doesn’t scale)
  • ❌ Use predictable session IDs
  • ❌ Send session cookies over HTTP
  • ❌ Trust client-provided session data

Error Handling

401 Unauthorized

Session expired or invalid:

403 Forbidden

CSRF token invalid:

Rate Limiting

Session authentication provides 15,000 requests/hour - the same as OAuth. Check rate limit status:

Complete Examples

Next.js App Router

Vue.js 3

Troubleshooting

Cookies Not Being Set

Cause: CORS configuration issue Solution:
  1. Ensure credentials: 'include' is set
  2. Add your domain to allowed origins in FLTR settings
  3. Use HTTPS in production (required for secure cookies)

CSRF Token Errors

Cause: Missing or invalid CSRF token Solution:

Session Expires Too Quickly

Cause: No activity extending session Solution: Make a lightweight request periodically:

Next Steps

API Keys

Compare with API key authentication

OAuth

When to use OAuth instead

CORS Guide

Configure CORS for your domain

Security

Security best practices