Documentation Index
Fetch the complete documentation index at: https://docs.esperr.com/llms.txt
Use this file to discover all available pages before exploring further.
What are Cookies?
Cookies are small pieces of data that websites store in your browser to remember information between visits. They’re essential for keeping users logged in, storing preferences, and tracking sessions.MDN Web DocsRead more on HTTP cookies.
Common Cookie Types
Session Cookies
- Purpose: Temporary storage during browsing session
- Examples:
PHPSESSID,session_id,_session - Lifetime: Until browser closes
- Security: Critical for authentication
Persistent Cookies
- Purpose: Remember users across visits
- Examples:
remember_me,user_preferences - Lifetime: Set expiration date
- Security: Can be convenience vs. security tradeoff
Tracking Cookies
- Purpose: Analytics and advertising
- Examples:
_ga(Google Analytics),fbp(Facebook) - Lifetime: Often months or years
- Security: Privacy considerations
Security Cookies
- Purpose: CSRF protection, security tokens
- Examples:
csrf_token,__Host-session - Lifetime: Varies by purpose
- Security: Critical for application security
How Cookies Work on the Web
- Server sends cookie: Via
Set-Cookieheader - Browser stores it: According to domain/path rules
- Browser sends it back: On every matching request
- Server reads cookie: To identify user/session
Using Cookies in Policies
Basic Examples
Require authentication cookie:Advanced Patterns
Session fixation detection:Cookie Attributes That Matter
| Attribute | Purpose | Security Impact |
|---|---|---|
| HttpOnly | No JavaScript access | Prevents XSS theft |
| Secure | HTTPS only | Prevents interception |
| SameSite | CSRF protection | Limits cross-site sending |
| Domain | Scope control | Prevents subdomain access |
| Path | URL restriction | Limits cookie availability |
Security Patterns
Detecting Session Hijacking
Preventing Cookie Stuffing
Invalid Cookie Formats
Best Practices
DO:
- Validate cookie formats - Ensure expected structure
- Monitor cookie combinations - Unusual sets might indicate attacks
- Track cookie age - Very old sessions might be compromised
- Check cookie presence - Missing auth cookies on protected resources
- Use with other signals - Combine with IP, user agent for better detection
DON’T:
- Trust cookie values - Users can modify them
- Store sensitive data - Even encrypted, it’s risky
- Block missing cookies carelessly - Some pages don’t need them
- Ignore cookie size - Large cookies can cause issues
- Forget about subdomains - Cookie scope matters
Common Attack Patterns
Cookie Poisoning
Privilege Escalation
Session Fixation
Working with Authentication
Multi-Factor Authentication Check
Remember Me Security
Cookie Forensics
Investigation TipsWhen investigating suspicious activity:
- Check cookie creation time vs. activity time
- Look for impossible cookie combinations
- Compare cookie values with server records
- Track cookie modifications over time
Browser Behavior Quirks
Third-Party Cookies
- Increasingly blocked by browsers
- May not be sent in embedded contexts
- Consider when building policies
Cookie Limits
- ~4KB per cookie
- ~50 cookies per domain
- Browsers handle limits differently
Troubleshooting
“Cookie policy not matching”- Check exact cookie name (case-sensitive)
- Verify cookie is sent on this path
- Confirm domain/subdomain scope
- Check SameSite restrictions
- Users might have cookies disabled
- Private browsing affects cookies
- Cookie might be expired
- Browser extensions might block cookies
Integration Patterns
Combine with IP Tracking
API vs. Browser Detection
Related Fields
- Headers - Cookies are sent via Cookie header
- Client IP - Often checked together for session security
- User Agent - Changes might indicate session hijacking
- Request Path - Different paths need different cookies