DatabaseSessionHandler
class DatabaseSessionHandler extends AbstractSessionHandler (View source)
Session save handler that stores session data in the database.
Traits
Provides extensions to this object to integrate it with standard config API methods.
Config options
| table_name | string |
Properties
Methods
Check the PHP session ID i.e. PHPSESSID is valid against the default PHP session ID format.
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
Gets the uninherited value for the given config option
Add the database table. This is called by an extension when building the db.
Details
protected int
getLifetime()
Get the session lifetime in seconds.
Returns the cookie lifetime if it's non-zero, otherwise returns the garbage collection lifetime.
protected void
checkSessionID(string $id)
Check the PHP session ID i.e. PHPSESSID is valid against the default PHP session ID format.
This is a security measure to prevent people from injecting invalid session IDs in the request.
This only needs to be called on read() We do not need to call this on write(), destroy(), updateTimestamp(), or validateId() as those methods are only called for session IDs that have already been accepted by PHP.
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
bool
open(string $path, string $name)
No description
bool
close()
No description
bool
destroy(string $id)
No description
int|false
gc(int $max_lifetime)
No description
string|false
read(string $id)
No description
bool
write(string $id, string $data)
No description
bool
validateId(string $id)
No description
bool
updateTimestamp(string $id, string $data)
No description
void
requireTable()
Add the database table. This is called by an extension when building the db.
Note that we don't just use a DataObject because:
- We don't want things like versioning, fluent, etc to ever be able to affect sessions
- We don't want developers to be affecting db operations via hooks (interact with sessions with the Session class)
- We don't want sessions to be used in any other ways that DataObjects are often
- We only want to build the table if this is the configured save handler