我有一个JavaScript弹出对话框,只要用户调用特定事件就会出现,这可能很烦人。
我在服务器端使用Ruby on Rails并使用数据库连接。
所以我正在考虑输入复选框,以便对话框不会再次显示,但用户应该能够再次更改该值。
我在哪里存储布尔值?在数据库,会话,甚至cookie?
答案 0 :(得分:7)
The answer is, "it depends". If you want the setting to persist across visits to the site, even from different computers, store it in the user's profile in your database. If you don't have a user database, store it in a persistent cookie. If you don't want it to persist (too long), store it in the (PHP?) session. If you won't want it to persist at all, store it in a per-session cookie (i.e. one without an expiry date)