def login():
    json = validate_input(request)
    if json is None:
        return Constants.ERROR_INVALID_INPUT

    try:
        msg = user.authenticateuser(json)
        expiry_time = Util.expiry_time()
        hash = Util.md5(json[Constants.EMAIL] + str(expiry_time))
        response.set_cookie(Constants.COOKIE_KEY, hash, httponly=True, expires=expiry_time)
        response.status = Constants.ACCEPTED  #login request successful
        return msg
    except Exception as e:
        response.status = Constants.AUTH_ERROR  #authentication failed
        return e