Is there any way to store user preference in a cookie or some db?
I have some user preferences like excluding some dates from a filter and want to maintain the preference when a user logs back in.
You can definitely use a database connection and access it via system.db.* functions.
As for cookie storage, not sure it's a thing yet with Ignition perspective. I used the search function on this forum and found this for you though.
Cache data between Perspective sessions on same device | Voters | Inductive Automation
Nothing with cookies yet, you'll have to utilize your DB and session custom properties.
What type of user source are you using? If you're using the Database user source (or any hybrid that involves the database), you can easily create a new table and make a foreign key constraint to the user table that has a user ID as a primary key.
For instance, one way to set up a user source would be to use a Database source with the Automatic option (that creates the DB model for you). After you create it, there are a few ways to proceed:
- You can create another table, maybe called
user_preference
in your DB and then foreign key to theusers
primary key. - You can use the pre-built
user_ex
table to store additional properties. Refer to the docs here to see the table structure.
-OR-
You could create a Database source in Manual mode, in which case you would have full control over the user*
tables. Then you could create as complex of a preferences
relationship to the user as you want. This requires some SQL knowledge.
This is, of course, just an example of a specific scenario that may or may not apply to you. I just wanted to point this out as an option for future viewers that are looking for options. We have run into this exact scenario many times, and we've approached it basically how I lined out above.
@flexware it is some filter that users can apply on a report, I want to save them for the user every time when he comes back at it. Its more like excluding some dates from the analysis when there is a non production day.
I like the idea @ryan.white mentioned in the other thread as storing session properties in a db and then loading them when a user logs back in.