2

I have a web app running on Bolt CMS and I need to be able to save some information across page loads so it's persistent. The data needs to be set via an AJAX call and retrieved within a Twig template. The trouble is, I don't know how I can do this within the Bolt environment (I've never used Symfony before)

I've seen quite a few similar questions on how to retrieve session variables within a Symfony controller but nothing on how to edit (or add a new) controller so that I can call it via AJAX to set the session variable

Thanks

jt78
  • 906
  • 2
  • 10
  • 22

1 Answers1

2

Because twig is rendered server-side, I assume you want to set something in one request, and then fetch it again on the next. I think you will need to create an extension for this, that stores the data in a table, and allows you to fetch it later. Take a look at the "WaffleOrders" extension for a good example on how to do this: https://github.com/bolt/WaffleOrders

This is all happening on the bolt side, though. To make it ajaxy, you should use jquery's ajax functionality to POST or GET the data, as needed.

Bopp
  • 664
  • 3
  • 5