Using SSL and cookies in curl

Using SSL and cookies in curl

Using SSL and cookies in curl

SSL

To enable SSL simply change http:// to https:// in the CURLOPT_URL option.
Some common options for curl when using SSL are CURLOPT_SSL_VERIFYHOST which when set to 1 verifies the existence

of a common name in the certificate and if set to 2 verifies the existence of a common name and that the common name in the certificate matches the host

name of the server. CURLOPT_SSLVERSION can be used to switch between SSL version 2 and 3, this is normally auto negotiated by PHP.

Cookies

Curl also has support for cookies. Cookie handling with curl is very simple. There are three options built into curl, CURLOPT_COOKIE,

CURLOPT_COOKIEJAR, and CURLOPT_COOKIEFILE. CURLOPT_COOKIE is used to set a cookie for the current session.

CURLOPT_COOKIEJAR stores the location of a file to store the cookies received when the session is closed. CURLOPT_COOKIEFILE stores the

location of a file containing cookies written in either Netscape format or raw HTTP header style.

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.