Before you begin part 1
We created two pages, the first one contains a dropdown menu and a button. Our visitors will select their country here and then they will be redirected, to the next page.
Before you begin part 2
On the next page, we have a dynamic table that displays database query results. Currently it shows all of the airports from the database but we are going to filter them by the country selected on the previous page. So, let's switch back to it and setup the cookie.
Setup the cookie
First, select cookie (1) in the HTML5 Data Bindings panel and click the add new button (2). Enter a name for the cookie (3) and click OK (4).
Add new behavior
Then, we select the plain HTML button (1) on our page and then we click the add new behavior button (2) in the behaviors panel. Select Control state management (4) from the DMXzone menu (3).
Customize the behavior
Open the action menu and select set cookie (1). Open the name menu and select the cookie (2) that we've already created. Click the dynamic data button (3).
Add cookie value
Under form, select your input field (1) and click OK (2).
Add one more behavior
We also add another behavior to this button, which will redirect the users to the next page. Click the go to URL behavior (2) from the behaviors menu (1).
Select your page
And here we select our page, containing the database query, that needs to be filtered (1). Click OK when you're done (2).
Now, let's go to the airports page (1). Our query returns all of the records from the database, so we need to filter it. Open globals (2) in the DMXzone Server Connect, right click cookie (3) and select add variable (4).
Enter valiable name
Enter the same name (1) that we used for the cookie on the previous page. Then click your query (2) and open its options (3).
In the filters tab (1), add the database column (2) that you want to filter your query by and click the add button (3). Click the server data bindings icon, in order to select a filter value.
Select filter value
You will find the cookie, under globals. Choose it (1) and click select button (2).
Select the same value for condition
We do the same for the condition (1). This way, the filter will be applied only when the condition is met. In this case, the condition is - when cookie named country exists. Click the OK button, when you are done (2).
Save and preview
Save your action file, and lets preview the results. When a visitor selects a country and presses the continue button a cookie is being set and then he gets redirected to the next page, where our database query results are. The query is now filtered by the country, selected on the previous page. Even if we go to some other page, and then return the query is still filtered. The filter will be applied until the cookie expires or its value changes.