2024-05-06 20:40:05 +00:00
|
|
|
---
|
2024-10-30 17:04:36 +00:00
|
|
|
date: 20201116
|
2024-05-06 20:40:05 +00:00
|
|
|
id: c6e1c9cf-d282-436e-b8fe-dbb62a1b2459
|
|
|
|
title: Stateless Route Attribute
|
|
|
|
---
|
|
|
|
|
|
|
|
# Description
|
|
|
|
|
|
|
|
When set to `true` declare that [session](20201109150950-sessions) can't
|
|
|
|
be used during handling of request. Generates Exception if route tries
|
|
|
|
to use the [session](20201109150950-sessions).
|
|
|
|
|
|
|
|
# Syntax
|
|
|
|
|
|
|
|
``` php
|
|
|
|
// src/Controller/MainController.php
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
|
|
|
|
|
class MainController extends AbstractController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @Route("/", name="homepage", stateless=true)
|
|
|
|
*/
|
|
|
|
public function homepage()
|
|
|
|
{
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|