Cookies with cURL

curl can specify and store the cookies encountered during HTTP operations.

The -cookieCOOKIE_IDENTIFER option specifies which cookies to provide. Cookies are defined as name=value. Multiple cookies should be delimited with a semicolon (;):

$ curl http://example.com --cookie "user=username;pass=hack"

The -cookie-jar option specifies the file to store cookies in:

$ curl URL --cookie-jar cookie_file

Get Linux Shell Scripting Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.