2024-05-06 20:40:05 +00:00
|
|
|
---
|
2024-10-30 17:04:36 +00:00
|
|
|
date: 20201109
|
2024-05-06 20:40:05 +00:00
|
|
|
id: 676f2820-f539-4b0a-8633-668fd0630c3c
|
|
|
|
title: Lazy Sessions
|
|
|
|
---
|
|
|
|
|
|
|
|
# Introduction
|
|
|
|
|
|
|
|
PHP 7.0 introduced a new interface called
|
|
|
|
`SessionUpdateTimestampHandlerInterface`. As of [Symfony
|
|
|
|
4.0](20201109140137-symfony_4_0) this has been added to the [PHP7
|
|
|
|
Polyfill component](20201109151215-symfony_php7_polyfill_component)
|
|
|
|
|
|
|
|
# Syntax
|
|
|
|
|
|
|
|
``` php
|
|
|
|
interface SessionUpdateTimestampHandlerInterface
|
|
|
|
{
|
|
|
|
// Checks if a session identifier already exists or not.
|
|
|
|
public function validateId(string $key) : bool;
|
|
|
|
|
|
|
|
// Updates the timestamp of a session when its data didn't change.
|
|
|
|
public function updateTimestamp(string $key, string $val) : bool;
|
|
|
|
}
|
|
|
|
```
|