- luci.fs.writefile(sessionpath .. "/" .. id, data)
- luci.fs.chmod(sessionpath .. "/" .. id, "a-rwx,u+rw")
-end
\ No newline at end of file
+ if not id:match("^%w+$") then
+ error("Session ID is not sane!")
+ end
+
+ local f = nixio.open(sessionpath .. "/" .. id, "w", 600)
+ f:writeall(data)
+ f:close()
+end
+
+
+--- Kills a session
+-- @param id Session identifier
+function kill(id)
+ if not id:match("^%w+$") then
+ error("Session ID is not sane!")
+ end
+ fs.unlink(sessionpath .. "/" .. id)
+end