How to set Cookie in CGI

The CGI, written in

C has the following statement
printf ("Set-Cookie:username =% s; path=/\ r\ n", username);
can be set successfully and can be read at the front end.
but if I want to set two values, I try the following methods:
printf ("Set-Cookie:username =% s; password =% s; path=/\ r\ n", username, password);
or
printf ("Set-Cookie:username =% s; path=/\ r\ n", username);
printf ("Set-Cookie:password =% s; path=/\ r\ n", password);

).

neither of these methods works, so how to set it

May.24,2021

has been solved. Just add expires after Set-Cookie, but you can't find the reason. You must bring expires?.


because you didn't say what the so-called "no" is, I guess it's because if you don't set expires, the cookie you set will be cleared after you close the conversation.

Menu