updated to store code in cookie with base64 encoding