What is the best way of storing persistent data ? I want to save the time the user was last active on the page.At first I used localstorage, then i switched to cookies because it seemed easier to use, now I'm thinking of storing it in a database.What do you suggest.
Also could you please suggest a good method of registering when a user left the page ?
Cookies are frequently used for storing non-critical user preferences that refer mostly to website usage, such as auto-login, language, themes, time zone etc. Since these are stored on user's local machine, cookies are client-side technology and can be deleted freely by the client, so you probably would not want to rely on cookies for storing critical data.
However, in case of storing domain-specific data, such as usernames, passwords, emails, favorites etc., you really might want to use a relational database (RDBMS), such as MySQL, MS SQL or PostgreSQL. These are viable on handling massive amounts of data and feature scores of useful features, i.e. transactions, efficiency, flexibility.