Skip to content
secondsky avatar

Session Management

Secure session management guide covering JWT access and refresh tokens, Redis storage, and cookie hardening.

CCM score
50 of 100
skills.sh installs
441
GitHub stars
257
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers token-based sessions with 1-hour access tokens and 7-day refresh tokens signed with separate secrets
  • Includes Redis-backed session storage with create and invalidate-all methods plus a 7-day key expiry
  • Enforces httpOnly, secure-in-production, and sameSite strict cookie settings, plus a refresh flow that rejects wrong token types
  • Designed for teams building authentication systems that need logout and per-user session invalidation

Install

$ npx -y skills add secondsky/claude-skills --skill session-management -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Session Management

Implement secure session management with proper token handling and storage.

Token-Based Sessions

const jwt = require('jsonwebtoken');

function generateTokens(user) {
  const accessToken = jwt.sign(
    { userId: user.id, role: user.role, type: 'access' },
    process.env.JWT_SECRET,
    { expiresIn: '1h' }
  );

  const refreshToken = jwt.sign(
    { userId: user.id, type: 'refresh' },
    process.env.REFRESH_SECRET,
    { expiresIn: '7d' }
  );

  return { accessToken, refreshToken };
}

Redis Session Storage

const redis = require('redis');
const client = redis.createClient();

class SessionStore {
  async create(userId, sessionData) {
    const sessionId = crypto.randomUUID();
    await client.hSet(`sessions:${userId}`, sessionId, JSON.stringify({
      ...sessionData,
      createdAt: Date.now()
    }));
    await client.expire(`sessions:${userId}`, 86400 * 7);
    return sessionId;
  }

  async invalidateAll(userId) {
    await client.del(`sessions:${userId}`);
  }
}

Cookie Configuration

Details

Repository
github.com/secondsky/claude-skills
Categories
Backend & APIs, Security
First seen
Jun 3, 2026

Questions

What does the session-management skill do?

The session-management skill implements secure sessions with JWT access and refresh tokens, Redis session storage, and cookie settings such as httpOnly, secure and sameSite. It also covers a token refresh route and invalidating all sessions for a user on logout.

How do I install the session-management skill?

Run npx -y skills add secondsky/claude-skills --skill session-management -y in your project to install it. Once installed, the agent can build authentication systems, manage user sessions and add secure logout using these session-management patterns.

Which category is session-management in, and what sets it apart?

session-management is listed in the Backend & APIs category on Claude Marketplaces. Within its own skill, it focuses on token-based sessions with Redis storage and refresh flows, rather than on the hosted backend services that neighboring skills cover.

Does session-management need any extra tools or keys?

The SKILL.md examples expect a JWT library such as jsonwebtoken, a Redis client, and secret values such as JWT_SECRET, REFRESH_SECRET and SESSION_SECRET set per environment. It also assumes HTTPS in production.

More from secondsky/claude-skills

All 116

Similar to Session Management

More Backend & APIs