GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸͺ NAME πŸͺ

set-cookie β€” (cookies) πŸ’…

okay so bestie, this is the manual page for set-cookie, and it lives in the Development manual, section 2gg. we are setting cookies today. it's giving bakery. πŸͺ✨


🎯 PURPOSE 🎯

Set cookie. that's the whole assignment. no notes. periodt. πŸ’…


πŸ“œ SYNTAX πŸ“œ

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

πŸ’– DESCRIPTION πŸ’–

To set a cookie named by the string <cookie name> to the string value <cookie value>, you use the set-cookie statement. and listen β€” a cookie must be set prior to outputting any actual response (like with output-statement or print-out, for example), or the program will error out and stop. so do it first, queen. don't be out here setting cookies after the reply already left the group chat. 😭

Cookie's <expiration> date (as a string, see get-time) is given with the expires clause. The default is a session cookie, meaning the cookie expires when the client session closes. lowkey the chillest default. 🫢

Cookie's <path> is specified with the path clause. The default is the URL path of the request URL. she just matches the vibe of where you already are. ✨

Whether a cookie applies to the same site is given with the same-site clause, along with possible values of "Lax", "Strict" or "None". pick your fighter. πŸ’…

By default a cookie is not accessible to client scripting (i.e. HttpOnly) -you can change this with the no-http-only clause. That will be the case if the no-http-only clause is used without the bool expression <no-http-only>, or if <no-http-only> evaluates to true. so true = the scripts can touch it. πŸ”₯

Use secure if a secure connection (https) is used, in order to specify this cookie is available only with a secure connection. That will be the case if secure is used without the bool expression <secure>, or if <secure> evaluates to true. πŸ”’

Cookies are commonly used for session maintenance, tracking and other purposes. Use get-cookie and delete-cookie together with set-cookie to manage cookies. the whole trio, fr fr. πŸ‘‘

You can set multiple cookies separated by a comma:

    get-time to tm year 1
    set-cookie "mycookie1"="4900" expires tm path "/", "mycookie2"="900" expires tm  path "/my-app" same-site "Strict"

(yes, there really are two spaces before path on that second one. keep it exactly like that, iykyk.) πŸ™ˆ


🌸 EXAMPLES 🌸

To set a cookie named "my_cookie_name" to value "XYZ", that will go with the reply and expire in 1 year and 2 months from now, use:

    get-time to mytime year 1 month 2
    set-string 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 the no-http-only clause):

    set-cookie "my_cookie_name"=my_cookie_value no-http-only

πŸ‘€ SEE ALSO πŸ‘€

  • Cookies
  • delete-cookie
  • get-cookie
  • set-cookie
  • See all documentation

okay that's the whole page, bestie, you ate. πŸŽ€

and one last thing before you go: this cutie of a page is dated $DATE and it's version $VERSION, so if you're citing her, that's the tea. bye, love you, go set some cookies responsibly. πŸ¦‹πŸ’œπŸŒˆ

πŸ“¦ where this page comes from