I have a set of sessions in a page, which I want to remove using AJAX. i.e click on a link, and without having to navigate for a new page, just remove the session, and show
Example controller:
use Symfony\Component\HttpFoundation\JsonResponse;
public function ajaxRemoveSessionAction()
{
// Destroy the desired session
$session = $this->getRequest()->getSession();
$session->remove('name');
return new JsonResponse(array('success' => true));
}
Example routing:
ajax_remove_session:
pattern: /remove-session
defaults: { _controller: FooTestBundle:Page:ajaxRemoveSession }
Example twig:
Remove session
These are just examples need testing.