summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/session.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/db/session.go b/db/session.go
index da081f9..7ebb6df 100644
--- a/db/session.go
+++ b/db/session.go
@@ -22,8 +22,8 @@ func (p *Phlox) CreateSession(user User) (Session, error) {
nowStr := now.Format(time.RFC3339)
_, err = p.db.Exec(
- "insert into sessions (sessionid, userid, created, modified) values (?, ?, ?, ?);",
- sessionid,
+ "insert into sessions (sessionid, userid, created, modified) values (?, ?, ?, ?);",
+ sessionid,
userid,
nowStr, nowStr,
)
@@ -107,6 +107,11 @@ func (p *Phlox) TouchSession(session Session) error {
}
+func (p *Phlox) TouchSessionId(id string) error {
+ return p.TouchSession(Session{ Id: id })
+}
+
+
func (p *Phlox) CleanSessions(maxIdle time.Duration) error {
expire := time.Now().UTC().Add(-maxIdle).Format(time.RFC3339)
_, err := p.db.Exec("delete from sessions where modified < ?;", expire)