John Davidson

php - delete or clear session in symfony 4.4


I am saving the current user s data in a session, I am using Symfony 4.4
I am getting and setting the data to the session variable this way

$session = $this->get('session');
$session->set('user', $user);

is there any way to clear and delete the session after logging out
I tried


and deleting the session one by using remove and nothing happened


My Answer:
$session->set('user', $userData);

To delete or clear the session in Symfony 4.4, you can use the following code:


This will remove the 'user' data from the session. If you want to clear the entire session, you can use:


This will remove all data from the session.

Rate this post

3 of 5 based on 2026 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us