Skip to content

cyx/cookie.lua

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 

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

About

basic cookie building / parsing for lua

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages