add authentication with cookies, add some comments