Reputation: 115
I am building a Backbone.js application with a Java-based backend. On the java side, the app is pretty much established. However, on the client side, there is a tiny detail I have to add. As part of a promotional campaign, I have to make sure that a permanent flash message is displayed to any user who is not logged in, as well as to any logged-in user, who hasn't intentionally closed it.
I know that normally, the best way to do it is to store the user decision in a boolean variable in the DB. The problem comes from the fact that I do not want to mess my backend code and the database with something like promotional messages. Therefore, I thought that maybe cookies set up from the client could help. However, this has the problem that I may end up with a separate cookie for every single account logged in form the same browser instance. And that just for one message. Plus, I cannot transfer cookies across browsers, so my users may end up seeing the message again
I am stuck. Please help. What I want is not even code, but just a few comments whether I am on the right track. If not, I will store in the DB anyway. It is just a bit of overhead for something as silly as promotional messages. Maybe redis can help?
Upvotes: 0
Views: 283
Reputation: 47833
Instead of cookies use localStorage
. It is easier and won't add additional data to every request to your servers. You will still have the downside however of it being browser sessions specific.
If you really want the promo status to persist over multiple computers you will have to store it in a database. If you already have redis up and running it will work but otherwise it would likely be more work than using your existing database.
Upvotes: 1