Sessions & Storage

Persist cookies across requests with named sessions, manage cookie jars, download files, and save responses to disk.

Named Sessions

Persistent Sessions

Use -N / --session to create a named session that persists cookies and custom headers across multiple requests. Sessions are stored on disk and survive between tgrs invocations.

# First request — login and save session cookies

tgrs POST https://api.example.com/login \

-N dev -d "username=admin&password=secret"

# Subsequent request — session cookies sent automatically

tgrs GET https://api.example.com/profile -N dev

# Another session for staging

tgrs GET https://staging-api.example.com/users -N staging

Tip: Use different session names for different environments (dev, staging, prod) to keep credentials and cookies separate.

Cookies

Send Cookies

Use -b / --cookie to send cookies with your request — inline or from a file.

# Inline cookies

tgrs GET https://api.example.com/data -b "session_id=abc123; lang=en"

# Cookies from file (Netscape format)

tgrs GET https://api.example.com/data -b @cookies.txt

Save Cookies to File

Use -c / --cookie-jar to save response cookies to a file in Netscape format.

# Save cookies to file

tgrs POST https://api.example.com/login -c cookies.txt

# Load and save cookies (round-trip)

tgrs GET https://api.example.com/data -b @cookies.txt -c cookies.txt

Save Response

Save Response Body to File

Use -o / --output to write the response body to a file.

# Save response to file

tgrs GET https://api.example.com/users -o response.json

tgrs GET https://api.example.com/users --output response.json

Download Mode

Download with Progress Bar

Use -D / --download to download files with a progress bar. Optionally specify a filename.

# Download a file (auto-detect filename)

tgrs GET https://example.com/files/report.pdf -D

# Download with specific name

tgrs GET https://example.com/files/report.pdf -D my-report.pdf

Filename is auto-detected from Content-Disposition header, URL, or Content-Type. If no filename can be determined, tgrs uses download.{ext} (e.g., download.png, download.json). If the file already exists, tgrs adds a number to avoid overwriting: download.png download(1).png download(2).png

Quick Reference

Session & Storage Flags

FlagAliasDescription
-N--sessionNamed session (persists cookies/headers)
-b--cookieSend cookies (inline or @file)
-c--cookie-jarSave cookies to file
-o--outputSave response body to file
-D--downloadDownload with progress bar