I have a table with pagination and a column that has 2 buttons you can toggle between for each row.
The buttons are pre-selected according to data from the database:
@foreach($rows as $row)
<tr>
<td> ... </td>
<td> ... </td>
<td>
<div class="buttons">
<button {{$row->type === "option1" ? "selected" : ""}}>Option 1</button>
<button {{$row->type === "option2" ? "selected" : ""}}>Option 2</button>
</div>
</td>
</tr>
@endforeach
The user can select choices accross the table, then he has a "save" button that saves all the updated selections.
The problem is that when the pagination link is clicked, the selections aren't saved.
I can save the data in a session, then merge the data from the DB data, and render the correct selections.
But I want to make it behave like it only saves the selections until a refresh. How can I do that? Persist the selections and also make a distinction between the pagination action and a refresh (or tab/browser closed)?