denisandroid
@denisandroid
BASH ,PHP , MYSQL, C++, JAVA . (PHP, JAVA,MYSQL)

Linux, Bash, Curl, Как сохранить сесию?

Как хранить сесию используя curl? У меня один скрипт вызывается на php и выполняется через curl. Но bash не хранит сесии так как просто вызывает curl дает ему post данные и ссылку, как можно это исправить?
  • Вопрос задан
  • 2528 просмотров
Пригласить эксперта
Ответы на вопрос 3
karabanov
@karabanov Куратор тега Linux
Системный администратор
Сохранить куки в файл. Подставлять куки в каждый запрос.


-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 cook‐
ies 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 writ‐
ten 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.
Ответ написан
Комментировать
microphone
@microphone
Сломалось - читай логи!
распарсить куки сохраненные в файле?
Ответ написан
denisandroid
@denisandroid Автор вопроса
BASH ,PHP , MYSQL, C++, JAVA . (PHP, JAVA,MYSQL)
Все всем спасибо!
TEMP=`curl -s -b '/tmp/uchat.cookies' -d 'type='$reads''$dop $URL -c '/tmp/uchat.cookies' $URL`
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы