dimanche 19 avril 2015

How to pass some custom cookie parameters in fastcgi

I have written a server in fcgi and C and I need to add some custome parameter after I printed some String to request.out. to be clear this is my sample code:



while (1)
{
rc = FCGX_Accept_r(&request);
if (rc < 0)
break;
FCGX_FPrintF(request.out,
"Content-type: text/html\r\n"
"\r\n");
//the html page content
FCGX_FPrintF(request.out,
"<form method=\"post\" action=\"\">"
"<input type=\"text\" name=\"num\">"
"<input type=\"submit\" value=\"click\" name=\"submit\">"
"</form>"
);
.
.
.

//and somewhere like here I need to add a cookie parameter
FCGX_FPrintF(request.out,
"set-cookie:myParam=myValue\r\n"
"\r\n");
.
.
.
.
FCGX_Finish_r(&request);
}


but this ends up printing right to the page.


how can I put it to the start of the buffer?


Thanks for your help.


Aucun commentaire:

Enregistrer un commentaire