Skip to content

what are the Stateless Routes? #50129

Answered by George-Gabro
mina20088 asked this question in Q&A
Discussion options

You must be logged in to vote

Indeed stateless refers that a route does not require any server-side state to be maintained between requests
here is code that will show error when using the server is this

class Controller extends AbstractController
{
/**
* @ route("/stateless", name="stateless_route", stateless=true)
*/
public function stateless(): Response
{
// Attempt to use the session
$session = $this->get('session');
$session->set('token', '123');

    // Return a response
    return new Response('dummy response');
}
}```

using $this->get('session') or any session methods are not allowed in this stateless route

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@mina20088
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by mina20088
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants