Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
bungle committed Sep 24, 2014
2 parents 77e8937 + 04a1600 commit 166236b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ http {
}
location /start {
content_by_lua '
local session = require "resty.session".start()
local session = require("resty.session").start()
session.data.name = "OpenResty Fan"
session:save()
ngx.say("<html><body>Session started. ",
Expand All @@ -26,24 +26,25 @@ http {
}
location /test {
content_by_lua '
local session = require "resty.session".start()
local session = require("resty.session").start()
ngx.say("<html><body>Session was started by <strong>",
session.data.name or "Anonymous",
"</strong>! <a href=/destroy>Destroy the session</a>.</body></html>")
';
}
location /destroy {
content_by_lua '
local session = require "resty.session".start()
local session = require("resty.session").start()
session:destroy()
ngx.say("<html><body>Session was destroyed. ",
"<a href=/check>Is it really so</a>?</body></html>")
';
}
location /check {
content_by_lua '
local session = require "resty.session".start()
ngx.say("<html><body>Session was really destroyed, you are known as <strong>",
local session = require("resty.session").start()
ngx.say("<html><body>Session was really destroyed, you are known as ",
"<strong>",
session.data.name or "Anonymous",
"</strong>! <a href=/>Start again</a>.</body></html>")
';
Expand Down Expand Up @@ -127,9 +128,9 @@ does also manage session cookie renewing configured with `$session_cookie_renew`
with a new expiration time if the following is met `session.expires - now < session.cookie.renew`.

```lua
local session = require "resty.session".start()
local session = require("resty.session").start()
-- Set some options (overwriting the defaults or nginx configuration variables)
local session = require "resty.session".start{ identifier = { length = 32 }}
local session = require("resty.session").start{ identifier = { length = 32 }}
```

#### boolean session:regenerate(flush or nil)
Expand All @@ -143,7 +144,7 @@ actually happens when the cookie's expiration time is not valid anymore). This f
value if everything went as planned (you may assume that it is always the case).

```lua
local session = require "resty.session".start()
local session = require("resty.session").start()
session:regenerate()
-- Flush the current data
session:regenerate(true)
Expand All @@ -157,7 +158,7 @@ advised that you call this function only once per request (no need to encrypt an
This function returns a boolean value if everything went as planned (you may assume that it is always the case).

```lua
local session = require "resty.session".start()
local session = require("resty.session").start()
session.data.uid = 1
session:save()
```
Expand All @@ -170,7 +171,7 @@ should remove the cookie, and not send it back again). This function returns a b
as planned (you may assume that it is always the case).

```lua
local session = require "resty.session".start()
local session = require("resty.session").start()
session:destroy()
```

Expand Down Expand Up @@ -201,15 +202,15 @@ you need to call `session:save` method.
**Setting session variable:**

```lua
local session = require "resty.session".start()
local session = require("resty.session").start()
session.data.uid = 1
session:save()
```

**Retrieving session variable (in other request):**

```lua
local session = require "resty.session".start()
local session = require("resty.session").start()
local uid = session.data.uid
```

Expand Down

0 comments on commit 166236b

Please sign in to comment.