Curl and cookies

I use cURL to enter the site, but I do not know how to get / use the cookies that I receive.

Does anyone have any ideas?

thanks

+3
source share
3 answers

Perhaps this example will help ...

#!/bin/bash
COOKIE_FILE="cookie.tmp"
MAIN_URL="http://localhost:8080/monitor"

if [ -e $COOKIE_FILE ] ; then
    rm $COOKIE_FILE
fi

curl -d "j_username=user&j_password=pass" -c $COOKIE_FILE "$MAIN_URL/j_spring_security_check"

DATA=`curl -b $COOKIE_FILE "$MAIN_URL/host/list.json"`

curl --get -b $COOKIE_FILE "$MAIN_URL/host/addHost.json?newHostAddress=192.168.77.197&newHostPort=9990"

rm $COOKIE_FILE
+2
source

curl_setopt($curl, CURLOPT_COOKIE, 'someKey=' . $_COOKIE['someVal . '; path=/');

cookie . cookie, php.net " cookie" cookie , "cookie jar"

+1

Source: https://habr.com/ru/post/1724948/


All Articles