CGILua
Building Web Scripts with Lua

Overview

CGILua includes a set of external libraries that allows the handling of Cookies, Sessions and Serialized data. To use these libraries just require them in your CGILua config.lua file.

Cookies

cgilua.cookies.get (name)
Gets the value of the cookie with the given name.
Returns a string with the value of the cookie.
cgilua.cookies.set (name, value[, options])
Sets the value of the cookie with a given name. The field names and values in the options table are used for the cookie attributes. This function should be called before the HTTP headers are sent and before any output is generated.
Returns nothing.
cgilua.cookies.sethtml (name, value[, options])
Sets the value of the cookie with a given name. This function generates a <meta> HTML element so it should be called after the <head> HTML tag was produced and before the corresponding </head>.
Returns nothing.
cgilua.cookies.delete (name[, options])
Deletes a cookie with a given name (setting its value to xxx).
Returns nothing.

Serialize

cgilua.serialize (table, outfunc[, indent[, prefix]])
Serializes a table using outfunc as the function to be used to generate the output; indent as an optional string with the indentation pattern; prefix as an optional string with the indentation prefix (it is used to store the actual indentation between the recursion calls).
Some restrictions must be noted: values of types function and userdata are not serialized; tables with cycles are not serialized.
Returns nothing.

Session

cgilua.session.close ()
Closes the user session. Saves all data in cgilua.session.data to the storage system being used (usually the filesystem). This function should be called after the end of the script execution. A recommended way to ensure that is to use addclosefunction in the configuration file.
Returns nothing.
cgilua.session.data
Table which holds the user session data.
cgilua.session.delete (id)
Deletes a session. The argument id is the session identifier.
Returns nothing.
cgilua.session.load (id)
Loads data from a session. The argument id is the session identifier.
Returns a table with session data or nil followed by an error message.
cgilua.session.new ()
Creates a new session identifier.
Returns the new session identifier.
cgilua.session.open ()
Opens the user session. Creates the table cgilua.session.data. This function should be called just before the execution of the script, but after the processing of the request's headers. A recommended way to ensure that is to use addopenfunction in the configuration file.
Returns nothing.
cgilua.session.save (id, data)
Saves data to a session with an id.
Returns nothing.
cgilua.session.setsessiondir (path)
Defines the session temporary directory. Argument path is a string with the new directory.
Returns nothing.

Valid XHTML 1.0!

$Id: libraries.html,v 1.22 2005/07/18 15:32:07 carregal Exp $