
Session Management
Covers the essentials for JWT-based session management with Redis storage, token refresh flows, and secure cookie configuration. You get working code for generating access and refresh tokens with different lifespans, a Redis-backed session store that handles multiple sessions per user, and proper cookie settings including httpOnly and sameSite flags. The refresh endpoint implementation is straightforward and the security guidelines are practical reminders about HTTPS-only, avoiding URL-based token transmission, and validating signatures. Use this when you're setting up authentication from scratch or need to replace an insecure session system. The Redis integration is particularly useful if you need to invalidate all sessions for a user during logout or password changes.
- skills.sh installs
- 427
- GitHub stars
- 248
- last updated
- Aug 21, 2026
Install
$ npx -y skills add secondsky/claude-skills --skill session-management --agent claude-codeInstalls into .claude/skills of the current project.
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
Sponsors
Details
- Repository
- github.com/secondsky/claude-skills
- Categories
- Backend & APIs, Security, Databases
- First seen
- Jun 3, 2026
More from secondsky/claude-skills
All 146- Ultracite426
- Nuxt Production425
- Api Gateway Configuration422
- Oauth Implementation422
- Nuxt Ui V4421
- Health Check Endpoints420
- Cloudflare D1416
- Api Changelog Versioning415
- Dependency Upgrade415
- Idempotency Handling415
- Nuxt Server415
- Turborepo414
- Mobile Offline Support412
- Recommendation System412
- Api Versioning Strategy410
- Claude Code Bash Patterns408
- Claude Hook Writer408
- Logging Best Practices408
- Cloudflare Manager407
- Plan Interview406
- Ml Pipeline Automation402
- Nuxt Core401
- Nuxt Data400
- Microservices Patterns398