Modified to use session variables and cookies to hold user information