Reputation: 12044
I am trying to get content of the page: I use google dev tool (network) and use "copy as curl" which gives me:
curl 'http://www.example.com/default.aspx/GetAnnonces' -H 'Cookie: `ASP.NET_SessionId=eolrcogrk1owhmpbsogwd0mf; EPC_alerte=;`
This works fine for a while, I guess beacuse of the session life period.
My question is:
Where the SessionId "eolrcogrk1owhmpbsogwd0mf" comes from and how to generate it so I can access the page any time ?
Upvotes: 2
Views: 354
Reputation: 11943
It comes from the Set-Cookie
HTTP response header of the page you visited. If you're trying to use cURL in PHP it will automatically handle cookies for you and you can set CURLOPT_COOKIEJAR
with curl_setopt
to retain cookies even after the request is complete.
If you just want to see the response headers you could also use curl_setopt($handle, CURLOPT_HEADER, true)
and look at the Set-Cookie
response headers. Though there's no practical reason for doing this for most typical use cases since cURL will just handle the cookies for you like your browser would.
Upvotes: 1