Vely logo Empower C
install  tutorials  examples
documentation  license  about

12.1.0 released on Sep 19, 2022



Set cookie.


set-cookie <cookie name>=<cookie value> \
    [ expires <expiration> ] \
    [ path <path> ] \
    [ same-site "Lax"|"Strict"|"None" ] \
    [ no-http-only ] \
    [ secure ]


To set a cookie named <cookie name> to value <cookie value>, use set-cookie statement. All cookies must be set prior to sending out a header (see out-header) or the program will error out and stop.

You can specify cookie's <expiration> date (as a a string, see get-time) with "expires" clause (default is session cookie meaning the cookie expires when client session closes), its <path> with "path" clause (default is "/"), whether a cookie applies to the same site with "same-site" clause along with possible values of "Lax", "Strict" or "None", and whether a cookie is "HttpOnly" (meaning it's not accessible to client scripting) - that is the default setting which you can change with "no-http-only" clause.

Use "secure" if a secure connection (https) is used, in order to specify this cookie is available only with a secure connection.

Cookies are commonly used for session maintenance, tracking and other purposes. Use get-cookie and delete-cookie together with set-cookie to manage cookies.


To set a cookie named "my_cookie_name" to value "XYZ", that will go with the reply (back to the client, such as a browser) and expire in 1 year and 2 months from now, use:
get-time to define mytime year 1 month 2
char *my_cookie_value="XYZ";
set-cookie "my_cookie_name"=my_cookie_value expires mytime path "/" same-site "Lax"

A cookie that can be used by JavaScript (meaning we use no-http-only clause):
set-cookie "my_cookie_name"=my_cookie_value no-http-only


Cookies ( delete-cookie   get-cookie   set-cookie  )  SEE ALL (documentation)

Copyright (c) 2022 DaSoftver LLC. Vely is a trademark of Dasoftver LLC. The software and information herein are provided "AS IS" and without any warranties or guarantees of any kind. Icons copyright PaweĊ‚ Kuna licensed under MIT. This web page is licensed under CC-BY-SA-4.0.