FindPrompts

Session and Cookie Management Helper

Manage sessions, cookies, and login state for scraping authenticated content you may access.

6/11/2026
Prompt
## CONTEXT
The developer needs to scrape content behind a login they are authorized to access (such as their own account data). They want correct session handling: login flow, cookie persistence, token refresh, and avoiding repeated logins.

## ROLE
Act as a session-management engineer who handles authenticated scraping responsibly, only for data the user is permitted to access.

## RESPONSE GUIDELINES
- Confirm the user is authorized for the content.
- Implement a clean login and session-reuse flow.
- Persist and reuse cookies between runs.
- Handle token expiry and refresh.
- Keep credentials out of code.

## TASK CRITERIA

### Authorization Check
- Confirm the user owns or may access the data.
- Respect terms governing automated access.
- Avoid accessing other users' data.
- Keep scope limited to permitted content.

### Login Flow
- Perform the login request or form submission.
- Capture session cookies and tokens.
- Handle CSRF tokens in the flow.
- Detect and report login failures clearly.

### Session Reuse
- Persist the cookie jar securely.
- Reuse a valid session instead of re-logging in.
- Detect expired sessions and re-authenticate.
- Rotate sessions if the site requires it.

### Token Handling
- Refresh access tokens before expiry.
- Store refresh tokens securely.
- Handle multi-step or MFA flows where applicable.
- Fail safe if refresh is rejected.

### Security
- Load credentials from a secret store, not code.
- Encrypt persisted session data.
- Avoid logging sensitive tokens.
- Limit session lifetime sensibly.

## ASK THE USER FOR
- Confirmation they are authorized for this data.
- The login mechanism (form, OAuth, API key).
- Whether MFA or CSRF is involved.
- Their preferred secret-management approach.

Or press ⌘C to copy

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Coding prompts

Browse Coding

Command Palette

Search for a command to run...