Answer the question
In order to leave comments, you need to log in
Linux, Bash, Curl, How to save a session?
How to store session using curl? I have one script called in php and executed via curl. But bash doesn't store sessions, so just calling curl gives it post data and a link, how can I fix this?
Answer the question
In order to leave comments, you need to log in
Save cookies to a file. Substitute cookies in every request.
-b, --cookie
(HTTP) Pass the data to the HTTP server as a cookie. It is supposedly the data previously received from the server in a "Set-Cookie:"
line. The data should be in the format "NAME1=VALUE1; NAME2=VALUE2".
If no '=' symbol is used in the line, it is treated as a filename to use to read previously stored cookie lines from, which should be
used in this session if they match. Using this method also activates the "cookie parser" which will make curl record incoming cookies
too, which may be handy if you're using this in combination with the -L, --location option. The file format of the file to read cookies
from should be plain HTTP headers or the Netscape/Mozilla cookie file format.
NOTE that the file specified with -b, --cookie is only used as input. No cookies will be stored in the file. To store cookies, use
the -c, --cookie-jar option or you could even save the HTTP headers to a file using -D, --dump-header!
If this option is used several times, the last one will be used.
-c, --cookie-jar
(HTTP) Specify to which file you want curl to write all cookies after a completed operation. Curl writes all cookies previously read
from a specified file as well as all cookies received from remote server(s). If no cookies are known, no file will be written. The
file will be written using the Netscape cookie file format. If you set the file name to a single dash, "-", the cookies will be written
to stdout.
This command line option will activate the cookie engine that makes curl record and use cookies. Another way to activate it is to use
the -b, --cookie option.
If the cookie jar can't be created or written to, the whole curl operation won't fail or even report an error clearly. Using -v will
get a warning displayed, but that is the only visible feedback you get about this possibly lethal situation.
If this option is used several times, the last specified file name will be used.
Thank you all!
TEMP=`curl -s -b '/tmp/uchat.cookies' -d 'type='$reads''$dop $URL -c '/tmp/uchat.cookies' $URL`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question