Possible Duplicate:
Cookie VS Session
PHP: How do Cookies and Sessions work?
I’m trying to learn PHP. I have a project website where numbers are constantly being generated, and changed and stored in javascript variables. There is very little php involved except in storing these variables to a database when the user hits the “store to database” button. Today I was using the site, navigated to another website and went back and all my data was gone as i had not stored it to the database first. I would like to save that data so it repopulates if I leave the page. what would be the best method of doing this? php sessions, cookies, or javascript cookies? please advise, thanks in advance!
There is either a session or cookie so there are two things not three.
Now a session is also a cookie but is saved on server unlike simple JS cookie which is saved in user’s machine.
If it is sensitive information, always use database to store it and if it is not sensitive data:
localStoragebut it can be deleted by userOn the other hand, to save it permanently, use the database instead.