SessionBootstrap
in package
Session bootstrap utility class.
Provides static methods for configuring and starting PHP sessions with proper security settings.
Tags
Table of Contents
Methods
- bootstrap() : void
- Initialize session and configuration.
- configureSessionCookie() : void
- Configure secure session cookie parameters.
- isSecureConnection() : bool
- Detect if the current request is over HTTPS.
- setConfigurationOptions() : void
- Set PHP configuration options like time limits and memory.
- setErrorReporting() : void
- Set error reporting level.
- startSession() : void
- Start the session and validate it.
Methods
bootstrap()
Initialize session and configuration.
public
static bootstrap() : void
Main entry point that sets up error reporting, configuration, and starts the session if needed.
configureSessionCookie()
Configure secure session cookie parameters.
public
static configureSessionCookie() : void
Sets HttpOnly, Secure, and SameSite flags to protect against:
- XSS attacks (HttpOnly prevents JavaScript access)
- Man-in-the-middle attacks (Secure ensures HTTPS-only transmission)
- CSRF attacks (SameSite restricts cross-site cookie sending)
isSecureConnection()
Detect if the current request is over HTTPS.
public
static isSecureConnection() : bool
Checks multiple indicators to handle proxies and load balancers.
Return values
bool —True if the connection is secure
setConfigurationOptions()
Set PHP configuration options like time limits and memory.
public
static setConfigurationOptions() : void
setErrorReporting()
Set error reporting level.
public
static setErrorReporting(bool $displayErrors) : void
Parameters
- $displayErrors : bool
-
True to enable all error reporting
startSession()
Start the session and validate it.
public
static startSession() : void