Maintaining session in cURL

I am sending a request to a server A. There, in the server I am using cURL to send request to a page on the same server(A). So, I am sending a request from A to A.

As I log into A, session will be established. Can’t I use the same session for cURL requests going from A to A?

Yes you can. Look at the “cookie” options that you can set using curl_set_opt.

have a look at

CURLOPT_COOKIEFILE: The name of the file containing the cookie data. The cookie file can be in Netscape format, or just plain HTTP-style headers dumped into a file.

But how can we know the name of the cookie on the client side? Can we use the same cookie in the server side cURL requests also?

A session will be created when client sends a request to server A. The same session should be used for the requests that are sent (using cURL) from A to A. Otherwise data will not be returned in the requests going from A to A.