Annotate

util/session.lua @ 6938:9df70e9e006b

util.session: What is the identity of a session?
author Kim Alvefur <zash@zash.se>
date Tue, 24 Nov 2015 19:09:51 +0100
parent 6937:f5d2e58fbefa
child 6939:a9ae0c6ac4f4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6937
f5d2e58fbefa util.session: What is a session?
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1
f5d2e58fbefa util.session: What is a session?
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 local function new_session(typ)
f5d2e58fbefa util.session: What is a session?
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 local session = {
f5d2e58fbefa util.session: What is a session?
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 type = typ .. "_unauthed";
f5d2e58fbefa util.session: What is a session?
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 };
f5d2e58fbefa util.session: What is a session?
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 return session;
f5d2e58fbefa util.session: What is a session?
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 end
f5d2e58fbefa util.session: What is a session?
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8
6938
9df70e9e006b util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents: 6937
diff changeset
9 local function set_id(session)
9df70e9e006b util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents: 6937
diff changeset
10 local id = typ .. tostring(session):match("%x+$"):lower();
9df70e9e006b util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents: 6937
diff changeset
11 session.id = id;
9df70e9e006b util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents: 6937
diff changeset
12 return session;
9df70e9e006b util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents: 6937
diff changeset
13 end
9df70e9e006b util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents: 6937
diff changeset
14
6937
f5d2e58fbefa util.session: What is a session?
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 return {
f5d2e58fbefa util.session: What is a session?
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 new = new_session;
6938
9df70e9e006b util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents: 6937
diff changeset
17 set_id = set_id;
6937
f5d2e58fbefa util.session: What is a session?
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 }