Is it possible to put a session via POST?

There is a script:

if (!isset($_SESSION['counter'])) {
 $_SESSION['counter'] = 0;

if ($_SESSION['counter'] > '30') { ####
 print 'limit';

print ++$_SESSION['counter'];

This script is invoked by the other using CURL:
$url = '';
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_HEADER, false);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_POST, true);
 $response = curl_exec($ch);

But it always returns 1.

Is it possible to set the counter call hook script using sessions?
June 5th 19 at 21:04
2 answers
June 5th 19 at 21:06
You need to configure curl to work with cookies:

curl_setopt ($ch, CURLOPT_COOKIEFILE, "/tmp/my_php_script_cookie_1.txt");
what should be in a txt? - Caterina.Blan commented on June 5th 19 at 21:09
, nothing. curl file itself creates and to work with him. - harmon_Carter86 commented on June 5th 19 at 21:12
June 5th 19 at 21:08
session ID written in the cookie (can be over and GET set up), so this script does not store cookies and so for the first code, always a new user

Find more questions by tags PHPSessions