To know how sessions work, there is one thing to do. Read about it. But I can give you a short intro on what a session is.
When you open a browser window and enters the website you start a new session. This session will run until it times out or you close the browser window.
In a session you can store values. That means that you can retrieve these values at any time in the session.
This is not a good explanation at all, but it's a very basic introduction on how you can use sessions.
I've used sessions when creating user areas. It's pretty easy to use and works fine for these kind of things.
What you need to do is to define what you want to keep track. When do you want to write to the database? When the users move around, or on a special action like a form submit?
Anyway sessions are good for this kind of work. There are som goood articles on this site on this subject.