libfetch 0.0.0
A lightweight asynchronous HTTP/1.1 client library implementing a subset of the WHATWG Fetch API.
Loading...
Searching...
No Matches
Cookie Attributes

Set and get cookie attributes. More...

Functions

void cookie_set_expires (cookie_t *cookie, time_t expires)
 Set cookie expiration time.
 
void cookie_set_max_age (cookie_t *cookie, int64_t max_age_seconds)
 Set cookie max-age.
 
void cookie_set_secure (cookie_t *cookie, bool secure)
 Set Secure flag.
 
void cookie_set_http_only (cookie_t *cookie, bool http_only)
 Set HttpOnly flag.
 
void cookie_set_samesite (cookie_t *cookie, cookie_samesite_t samesite)
 Set SameSite attribute.
 
void cookie_set_priority (cookie_t *cookie, cookie_priority_t priority)
 Set Priority attribute.
 

Detailed Description

Set and get cookie attributes.

Function Documentation

◆ cookie_set_expires()

void cookie_set_expires ( cookie_t * cookie,
time_t expires )

Set cookie expiration time.

Parameters
cookieCookie to modify
expiresExpiration timestamp (0 for session cookie)
time_t one_hour = time(NULL) + 3600;
HTTP cookie structure.
Definition cookie.h:105

◆ cookie_set_http_only()

void cookie_set_http_only ( cookie_t * cookie,
bool http_only )

Set HttpOnly flag.

Parameters
cookieCookie to modify
http_onlyTrue to prevent JavaScript access

◆ cookie_set_max_age()

void cookie_set_max_age ( cookie_t * cookie,
int64_t max_age_seconds )

Set cookie max-age.

Parameters
cookieCookie to modify
max_age_secondsMax age in seconds (negative to delete immediately)
// Set cookie to expire in 1 hour
// Delete cookie immediately

◆ cookie_set_priority()

void cookie_set_priority ( cookie_t * cookie,
cookie_priority_t priority )

Set Priority attribute.

Parameters
cookieCookie to modify
priorityPriority level

◆ cookie_set_samesite()

void cookie_set_samesite ( cookie_t * cookie,
cookie_samesite_t samesite )

Set SameSite attribute.

Parameters
cookieCookie to modify
samesiteSameSite value

◆ cookie_set_secure()

void cookie_set_secure ( cookie_t * cookie,
bool secure )

Set Secure flag.

Parameters
cookieCookie to modify
secureTrue to require HTTPS