Ideas on how to make game resource graph like in travian?

What i need to make is like in travian, users have their wood, wheat such increasing wether you are on the page or not in the page.

i have been thinking on how to accomplish anything like that;

best idea would be;

**when user leaves the web site **

[LIST]
[*]i can get that date and save it on mysql
[/LIST]
**when user logs on **

[LIST]
[*]get the current date and find the difference since he last visited.
[/LIST]
[U]According to the resources i need to know how much resources i do produce per hour. Since i do know this i can calculate to see how much resources must have been produced since the user last logged on.

then add that resources back to the database.
then show whats current and add that to your ENTER_FRAME function.[/U]

[COLOR=DarkRed]This is not a server-side running script.
What is you guys’ ideas in order to accomplish the similar and performance consuming work ?[/COLOR]