SkillAgentSearch skills...

Cookie.lua

basic cookie building / parsing for lua

Install / Use

/learn @cyx/Cookie.lua
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

cookie.lua

usage

local cookie = require("cookie")

-- basic usage
assert("foo=bar" == cookie.build({ foo="bar" }))

-- using all possible option values
local time = 1398283214

local options = {
	max_age = 3600,
	domain = ".example.com",
	path = "/",
	expires = time,
	http_only = true,
	secure = true
}

local expected =
	"foo=bar; Max-Age=3600; Domain=.example.com; " ..
	"Path=/; Expires=Wed, 23 Apr 2014 13:01:14 GMT; " ..
	"HttpOnly; Secure"

assert(expected == 
	cookie.build({ foo="bar" }, options))

-- parsing
assert(equal({ foo="bar", bar="baz" },
	cookie.parse("foo=bar; bar=baz")))

assert(equal({ foo="bar", bar="baz" },
	cookie.parse('foo=bar; bar="baz"')))

assert(equal({ foo="bar", bar="baz" },
	cookie.parse('foo=bar; bar="baz"; foo=baz')))

assert(equal({ foo="bar", bar="baz" },
	cookie.parse('foo=bar; bar="baz"; barabaz')))

license

MIT

View on GitHub
GitHub Stars10
CategoryDevelopment
Updated8mo ago
Forks3

Languages

Lua

Security Score

67/100

Audited on Jul 10, 2025

No findings