Do I Need To Pay VAT?

I’m writing a C++ client which is using libcurl for communicating with a PHP script.

The communication should be session based, and thus the first task is to login and make the PHP script set up a session.

I’m not used to working with sessions either from C++ or PHP. I basically know that it has to do with cookies and communicating session id.

I can’t find any example on the curl homepage which demonstrates a simple session management use case.

I’m assuming it has something to do with one or many of the following options in curl:


But I can’t really see the big picture just from the documentation of CURLOPT_COOKIESESSION for instance.

Anybody who has done this, please share a simple piece of code which shows the concept.




February 16, 2017 at 10:18 am admin

A session in PHP has the purpose of preserving some state over several requests, since HTTP in itself is stateless. To get a session from PHP, simply request a php page that starts a session, and keep the cookie you get back for subsequent requests.

Starting a session in php is simple – call the session_start() function. That function will resume an existsing session if the cookie exists in the request. When the session is started, persistent variables can be set using the superglobal array $_SESSION. It’s a good idea to store a ‘is logged in’-token there =) To end the PHP session, set $_SESSION to array(), so that the token is destroyed.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.