first version with commented code of cookie and database access