aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiale Zhi <vipcalio@gmail.com>2014-03-21 13:27:00 -0700
committerJiale Zhi <vipcalio@gmail.com>2014-03-21 13:27:00 -0700
commit15f37bfd0362ec710cc3515043c05ecdc47927af (patch)
tree70441cf0dca2df78b823ff5e3e7749e36624951a
parent71ecd7486d6d777708adcf6c2883716f07f8aa52 (diff)
downloadlua-resty-cookie-15f37bfd0362ec710cc3515043c05ecdc47927af.tar.gz
lua-resty-cookie-15f37bfd0362ec710cc3515043c05ecdc47927af.tar.bz2
lua-resty-cookie-15f37bfd0362ec710cc3515043c05ecdc47927af.zip
Update synopsis
-rw-r--r--README.md35
1 files changed, 33 insertions, 2 deletions
diff --git a/README.md b/README.md
index 3fdae66..3db377d 100644
--- a/README.md
+++ b/README.md
@@ -32,14 +32,45 @@ Synopsis
return
end
- local field = cookie:get("lang")
+ -- get single cookie
+ local field, err = cookie:get("lang")
+ if not field then
+ ngx.log(ngx.ERR, err)
+ return
+ end
ngx.say("lang", " => ", field)
- local fields = cookie:get_all()
+ -- get all cookies
+ local fields, err = cookie:get_all()
+ if not fields then
+ ngx.log(ngx.ERR, err)
+ return
+ end
for k, v in pairs(fields) do
ngx.say(k, " => ", v)
end
+
+ -- set one cookie
+ local ok, err = cookie:set({
+ key = "Name", value = "Bob", path = "/",
+ domain = "example.com", secure = true, httponly = true,
+ expires = "Wed, 09 Jun 2021 10:18:14 GMT", max_age = 50,
+ extension = "a4334aebaec"
+ })
+ if not ok then
+ ngx.log(ngx.ERR, err)
+ return
+ end
+
+ -- set another cookie, both cookies will appear in HTTP response
+ local ok, err = cookie:set({
+ key = "Age", value = "20",
+ })
+ if not ok then
+ ngx.log(ngx.ERR, err)
+ return
+ end
}
}