session.php
Table of Contents
Functions
- session() : Session
- Retrieve the current session instance.
- error() : string|null
- Retrieves the first error message for a specific field from the session.
- old() : mixed|null
- Retrieve old input data for a given field from the session.
Functions
session()
Retrieve the current session instance.
session() : Session
This function provides access to the session instance managed by the application.
Return values
Session —The current session instance.
error()
Retrieves the first error message for a specific field from the session.
error(string $field) : string|null
This function accesses the session to fetch error messages stored under
a predefined key. If there are multiple error messages for the given field,
only the first one is returned. If no errors exist for the field, null
is returned.
Parameters
- $field : string
-
The name of the field for which to retrieve the error message.
Return values
string|null —The first error message for the specified field, or null
if no errors exist.
old()
Retrieve old input data for a given field from the session.
old(string $field) : mixed|null
This function fetches the value of a specific field from the old input data stored in the session. If the field does not exist, it returns null.
Parameters
- $field : string
-
The name of the field to retrieve old input data for.
Return values
mixed|null —The value of the old input data for the specified field, or null if not found.