wkx_session_read()
The read callback must always return a session encoded (serialized) string, or an empty string if there is no data to read.
wkx_session_read(string $sessionId) : string
This callback is called internally by PHP when the session starts or when session_start() is called.
Before this callback is invoked PHP will invoke the open callback.
The value this callback returns must be in exactly the same serialized format that was originally passed for storage
to the write callback. The value returned will be unserialized automatically by PHP and used to populate the $_SESSION superglobal.
While the data looks similar to serialize() please note it is a different format which is specified in the session.serialize_handler ini setting.
Parameters
-
$sessionId
: string
-
Return values
string
—
wkx_session_write()
The write callback is called when the session needs to be saved and closed.
wkx_session_write(string $sessionId, string $sessionData) : bool
This callback receives the current session ID a serialized version the $_SESSION superglobal.
The serialization method used internally by PHP is specified in the session.serialize_handler ini setting.
The serialized session data passed to this callback should be stored against the passed session ID.
When retrieving this data, the read callback must return the exact value that was originally passed to the write callback.
This callback is invoked when PHP shuts down or explicitly when session_write_close() is called.
Note that after executing this function PHP will internally execute the close callback.
Parameters
-
$sessionId
: string
-
-
$sessionData
: string
-
Return values
bool
—
wkx_session_gc()
The garbage collector callback is invoked internally by PHP periodically in order to purge old session data.
wkx_session_gc(int $maxSessionLifetime) : bool
The frequency is controlled by WIKINDX_SESSION_GC_FREQUENCY.
The value of lifetime which is passed to this callback is a fallback set in session.gc_maxlifetime.
The real value of lifetime is:
- WIKINDX_SESSION_AUTH_MAXLIFETIME for sessions which have been authenticated at least once.
- WIKINDX_SESSION_AUTH_REMEMBERME_MAXLIFETIME for sessions which have been authenticated at least once with a "Remember Me" flag.
- WIKINDX_SESSION_NOTAUTH_MAXLIFETIME for sessions which have never been authenticated.
Return value should be true for success, false for failure.
Parameters
-
$maxSessionLifetime
: int
-
Return values
bool
—