Ulfius
HTTP Framework for REST Applications in C
Functions
Cookies

Functions

int ulfius_add_cookie_to_response (struct _u_response *response, const char *key, const char *value, const char *expires, const unsigned int max_age, const char *domain, const char *path, const int secure, const int http_only)
 
int ulfius_add_same_site_cookie_to_response (struct _u_response *response, const char *key, const char *value, const char *expires, const unsigned int max_age, const char *domain, const char *path, const int secure, const int http_only, const int same_site)
 

Detailed Description

Cookies management functions

Function Documentation

◆ ulfius_add_cookie_to_response()

int ulfius_add_cookie_to_response ( struct _u_response response,
const char *  key,
const char *  value,
const char *  expires,
const unsigned int  max_age,
const char *  domain,
const char *  path,
const int  secure,
const int  http_only 
)

ulfius_add_cookie_to_response add a cookie to the cookie map

Parameters
responsethe response to add the cookie to
keythe cookie key
valuethe cookie value
expiresthe expiration date of the ccokie in ISO format (optional)
max_agethe maximum age of the cookie in seconds (optional)
domainthe domain of the cookie (optional)
paththe path of the cookie (optional)
securewether the cookie must be secure or not (optional)
http_onlywether the cookie must be used only for http requests or not (optional)
Returns
U_OK on success

◆ ulfius_add_same_site_cookie_to_response()

int ulfius_add_same_site_cookie_to_response ( struct _u_response response,
const char *  key,
const char *  value,
const char *  expires,
const unsigned int  max_age,
const char *  domain,
const char *  path,
const int  secure,
const int  http_only,
const int  same_site 
)

ulfius_add_same_site_cookie_to_response add a cookie to the cookie map with a SameSite attribute

Parameters
responsethe response to add the cookie to
keythe cookie key
valuethe cookie value
expiresthe expiration date of the ccokie in ISO format (optional)
max_agethe maximum age of the cookie in seconds (optional)
domainthe domain of the cookie (optional)
paththe path of the cookie (optional)
securewether the cookie must be secure or not (optional)
http_onlywether the cookie must be used only for http requests or not (optional)
same_siteparameter must have one of the following values:
  • U_COOKIE_SAME_SITE_NONE - No SameSite attribute
  • U_COOKIE_SAME_SITE_STRICT - SameSite attribute set to 'Strict'
  • U_COOKIE_SAME_SITE_LAX - SameSite attribute set to 'Lax'
Returns
U_OK on success