scache_getopt
Description
scache_getopt queries session's options. Queryable options are :
- SCACHE_OPT_EXPIRES : current session timeout. Timeout is set when creating session or later changed by scache_setopt
- SCACHE_OPT_KEEPONELIMIT : action to do if backend hits memory or node limits. If value is true, session is kept and error reported. If value is false, session is destroyed from scached memory.
Note: this is a grave error situation, as scached backend expects to have enough memory and client is expected to control amount of data used. Default action is to destroy session are assume client to panic and inform user.
Parameters
Return values
Current setting of specified option (that might also be FALSE) or FALSE on error.
In case of failure, error codes resolvable by scache_lasterr is one of below :
- SCERR_NO_SESSION Connected session does not exist or has been expired. Connection is not valid any more.
- SCERR_NOT_CONNECTED Connection to backend is broken and cannot be reconnected.
- SCERR_PROTOCOL Internal protocol error has occurred when communicating to backend. This indicates something is severely broken.
Notes
One method of detecting forcibly killed session is to expect some parameter be always found from sessions keyspace. This can be se on session initialization, it might be loginname or it might be just dummy flag like 'i_am_alive', but if it doest not exists on further session connection, client is set to forward user to system error page.
Examples
<?php /* get connection */ $timeout = 600; $hostname = false; $secret = false; $session = scache_reset('MyEasilyGuessableSecret', $host, $secret, $timeout); if (scache_getopt($session, SCACHE_OPT_EXPIRES) != $timeout) { echo "scache is broken\n"; } ?>