Overview
Leaf v1.3.0 comes along with support for the native PHP session. We have directly tied it into leaf's core as a module, so you can use it without middleware
as done in some other API based frameworks.
Including Session
To include the Session object in a route, use this:
$session
to the Session
class, and we pass it into the route with use()
.
Session Methods
Starting a new session
Starting a new session with leaf is actually very simple😅..
set()
set() simply adds another key value pair to the native $_SESSION array. It takes in 2 parameters: The array key and it's pair..both as strings
getParam()
getParam is a method built for APIs, but can be used in a normal web app/website. It takes in one parameter: the name of the param passed into the app through the session
It works just like how $_SESSION['key']
does
getBody()
getBody() returns the key => value pairs of all the session data including any CSRF data
Next Steps
Simple RoutingResponse
Simple Authentication
Database Config