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