Where should I store block state for session duration?

Where should I store block state for session duration?

by Kevin Wiliarty -
Number of replies: 0

The "Filtered course list" block (https://moodle.org/plugins/block_filtered_course_list) displays courses that a user has (potential) access to. The courses are filtered by criteria an admin designates and grouped into collapsible rubrics according to those criteria. An admin can also designate the initial state of each rubric: expanded or collapsed.

At present there is no mechanism to keep track of which state a user has left a rubric in. A user might open a collapsed rubric, for instance, but when the page is refreshed it will be collapsed again. I am considering adding some mechanism for persistence, but then I have two questions:

  1. What is the best way to keep track of rubric states, ideally just for the duration of a session?
  2. Depending on #1, what are the GDPR implications?
The possible mechanisms I can think of are:

  1. A cookie, which has the virtue of being available both to PHP and Javascript
  2. Adding it to the global SESSION variable.
  3. As a "Persistent" (https://docs.moodle.org/dev/Persistent), though I don't really want the state to outlive a session.
Is there any Moodle policy or best practice that could guide me in this choice?

Average of ratings: -