I have a web app working fully Ajax wise. The user has the opportunity to apply a location filter. He or she can enter a city or region for instance. If that variable is set, I will use it as parameter in all my ajax calls.
My question is as follows: what is the best “place” to store that variable?
I hesitate between two solutions:
- The first idea is to create an attribute called location that I integrate in an element with a value equal to the user input.
- My second idea is to store the variable in my session array.
If there is a better idea out there I take it.
Use a session variable. This value is assumed to be near-constant over the session, so you shouldn’t send it at every request.