Session

Provides some persistent storage, kinda like PHP But, you have to manually commit() the data back to a file. You might want to put this in a scope(exit) block or something like that.

Constructors

this
this(Cgi cgi, CookieParams cookieParams, bool useFile, bool readOnly)

Loads the session if available, and creates one if not. May write a session id cookie to the passed cgi object.

Members

Functions

clear
void clear()

Clears the session data from both memory and disk. The session id is not changed by this function. To change it, use invalidate() if you want to clear data and change the ID or regenerateId() if you want to change the session ID, but not change the data.

commit
void commit(bool force)

Commits your changes back to disk.

hasKey
bool hasKey(string key)

like opIn

invalidate
void invalidate()

Kill the current session. It wipes out the disk file and memory, and changes the session ID.

regenerateId
void regenerateId()

Creates a new cookie, session id, and csrf token, deleting the old disk data. If you call commit() after doing this, it will save your existing data back to disk. (If you don't commit, the data will be lost when this object is deleted.)

reload
void reload()

Discards your changes, reloading the session data from the disk file.

Properties

opDispatch
string opDispatch [@property setter]

get/set for strings

Static functions

garbageCollect
void garbageCollect(bool delegate(string[string] data) finalizer, Duration maxAge)

Call this periodically to clean up old session files. The finalizer param can cancel the deletion of a file by returning false.

Meta