<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def frontendediting_request_processor(page, request):
 """ Sets the frontend editing state in the cookie depending on the ``frontend_editing`` GET parameter and the user's permissions. """

    if 'frontend_editing' not in request.GET:
        return

    response = HttpResponseRedirect(request.path)

    if request.user.has_module_perms('page'):

        if 'frontend_editing' in request.GET:

            try:
                enable_fe = int(request.GET['frontend_editing']) > 0
            except ValueError:
                enable_fe = False

            if enable_fe:
                response.set_cookie(str('frontend_editing'), enable_fe)
                clear_cache()
            else:
                response.delete_cookie(str('frontend_editing'))
                clear_cache()
    else:
        response.delete_cookie(str('frontend_editing'))

    # Redirect to cleanup URLs
    return response